package com.yanqu.road.server.manger.activity;

import com.alibaba.fastjson.JSONObject;
import com.yanqu.road.dao.impl.activity.zhenhuan.UserZhenHuanPartyHistoryDaoImpl;
import com.yanqu.road.dao.impl.player.*;
import com.yanqu.road.entity.activity.*;
import com.yanqu.road.entity.activity.evefeast.UserEveFeastData;
import com.yanqu.road.entity.activity.guagifts.UserGuaGiftData;
import com.yanqu.road.entity.activity.iceservergift.IceServerGiftMallRecord;
import com.yanqu.road.entity.activity.musicroomrank.UserMusicRoomRankBeautyData;
import com.yanqu.road.entity.activity.oldplayerreturn.OldPlayerReturnUserData;
import com.yanqu.road.entity.activity.shuihu.ShuiHuUserData;
import com.yanqu.road.entity.activity.shuihu.config.ShuiHuConfig;
import com.yanqu.road.entity.activity.starlight.StarLightMallRecord;
import com.yanqu.road.entity.activity.winterLove.WinterLoveUserData;
import com.yanqu.road.entity.activity.winterLove.config.WinterLoveConfig;
import com.yanqu.road.entity.activity.xiaowuRecall.XiaowuRecallUserData;
import com.yanqu.road.entity.activity.xiaowuRecall.config.XiaowuConfig;
import com.yanqu.road.entity.activity.zhenhuan.secondProcess.UserZhenHuanPartyHistoryData;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.activity.chefDuel.eChefDuelActivityType;
import com.yanqu.road.entity.enums.activity.eActivityChargeType;
import com.yanqu.road.entity.enums.activity.zhenhuan.eZhenHuanChildType;
import com.yanqu.road.entity.enums.*;
import com.yanqu.road.entity.language.LanguageType;
import com.yanqu.road.entity.log.LogToyHouseCandy;
import com.yanqu.road.entity.log.LogXiaowuRecallReward;
import com.yanqu.road.entity.player.UserHistoryAttribute;
import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.entity.qixi.UserQixiGiftData;
import com.yanqu.road.logic.bussiness.activity.*;
import com.yanqu.road.logic.bussiness.player.UserActivityBussiness;
import com.yanqu.road.logic.bussiness.player.UserHistoryAttributeBussiness;
import com.yanqu.road.logic.bussiness.servercenter.ActivityBussiness;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.logic.helper.ActivityHelper;
import com.yanqu.road.logic.rank.RankListModel;
import com.yanqu.road.logic.rank.UnionActivityRankListModel;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.ActivityModule;
import com.yanqu.road.server.gameplayer.module.banquet.BanquetModule;
import com.yanqu.road.server.gameplayer.module.player.AttributeModule;
import com.yanqu.road.server.gameplayer.module.player.PlayerModule;
import com.yanqu.road.server.logic.activity.condition.normal.RechargeVipDayCondition;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.MultipleLanguageMgr;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.server.manger.ServerListMgr;
import com.yanqu.road.server.manger.VipMgr;
import com.yanqu.road.server.manger.activity.chinesechess.ChineseChessMgr;
import com.yanqu.road.server.manger.activity.goldingotfund.GoldIngotFundMgr;
import com.yanqu.road.server.manger.activity.gourdchild.GourdChildMgr;
import com.yanqu.road.server.manger.activity.gourdplant.GourdPlantMgr;
import com.yanqu.road.server.manger.activity.guagifts.GuaGiftsMgr;
import com.yanqu.road.server.manger.activity.oldplayerreturn.OldPlayerReturnMgr;
import com.yanqu.road.server.manger.activity.qixi.QixiMgr;
import com.yanqu.road.server.manger.activity.shuihu.ShuiHuMgr;
import com.yanqu.road.server.manger.activity.treasure.TreasureActivityMgr;
import com.yanqu.road.server.manger.activity.winterLove.WinterLoveMgr;
import com.yanqu.road.server.manger.activity.xiaowuRecall.XiaowuRecallMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.manger.rank.ActivityRankMgr;
import com.yanqu.road.server.manger.rank.RankMgr;
import com.yanqu.road.server.manger.union.UnionActivityMgr;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class NormalActivityMgr extends TempMgr {

    private static Logger logger = LogManager.getLogger(NormalActivityMgr.class.getName());

    private static Map<Integer, ActivityInfo> showTimeActivityInfoMap = new ConcurrentHashMap<>();

    private static Map<Integer, ActivityInfo> allActivityInfoMap;

    private static Map<Integer, List<ActivityConditionInfo>> activityConditionInfoMap;

    private static Map<Integer, ActivityDetail> activityDetailMap;

    private static Map<Integer, Map<Integer, MallInfo>> allActivityMallInfoMap;  //活动商城

    private static Map<Integer, Map<String, ActivityConfig>> activityConfigMap; //活动配置

    private static Map<Integer, Map<Integer, Integer>> triggerRevisionMap = new ConcurrentHashMap<>();

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }

    @Override
    public boolean save() {
        List<ActivityDetail> activityDetailList = new ArrayList<>(activityDetailMap.values());
        for (ActivityDetail activityDetail : activityDetailList) {
            if (activityDetail.isInsertOption()) {
                UserActivityBussiness.addActivityDetail(activityDetail);
            } else if (activityDetail.isUpdateOption()) {
                UserActivityBussiness.updateActivityDetail(activityDetail);
            }
        }
        return true;
    }

    @Override
    public boolean reloadData() {
        activityDetailMap = UserActivityBussiness.getActivityDetailMap();
        return true;
    }

    public static Map<Integer, ActivityInfo> getAllActivityInfoMap() {
        return allActivityInfoMap;
    }

    public static Map<Integer, ActivityDetail> getActivityDetailMap() {
        return activityDetailMap;
    }

    /**
     * 获取过期5天内的需要自动发奖的活动
     * @return
     */
    public static List<Integer> getExpiredActivityBiggerThanFiveDayList() {
        List<Integer> list = new ArrayList<>();
        long nowTime = System.currentTimeMillis();
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (ActivityMgr.isMyActivityType(activityInfo, eActivityType.RechargeActivity, eActivityChargeType.EveryDayCharge) ||
                    ActivityMgr.isMyActivityType(activityInfo, eActivityType.RechargeActivity, eActivityChargeType.DaysCharge) ||
                    ActivityMgr.isMyActivityType(activityInfo, eActivityType.RechargeActivity, eActivityChargeType.AllCharge) ||
                    ActivityMgr.isMyActivityType(activityInfo, eActivityType.RechargeActivity, eActivityChargeType.NewEveryDayCharge) ||
                    ActivityMgr.isMyActivityType(activityInfo, eActivityType.RechargeActivity, eActivityChargeType.CanReissueDaysCharge)) {
                if (nowTime <= (activityInfo.getEndShowTime() * 1000 + 5 * 24 * 3600 * 1000)) {
                    list.add(activityInfo.getActivityId());
                }
            }
        }
        return list;
    }

    public static void reloadActivityData(Map<Integer, ActivityInfo> activityInfoMap, Map<Integer, List<ActivityConditionInfo>> tempActivityConditionInfoMap,
                                          Map<Integer, Map<Integer, MallInfo>> inActivityMallInfoMap, Map<Integer, Map<String, ActivityConfig>> inActivityConfigMap) {
        logger.info("reload normal activity start");
        //从数据库读出未完成活动信息
        Map<Integer, ActivityInfo> tempActivityInfoMap = new ConcurrentHashMap<>(activityInfoMap);
        for (ActivityDetail activityDetail : activityDetailMap.values()) {
            if (activityDetail.getAutoSendRewardState() == 1) {//已经发完奖励的
                ActivityInfo tInfo = activityInfoMap.get(activityDetail.getActivityId());
                if (tInfo != null && (tInfo.getType() == eActivityType.CrossHolidayActivity.getValue() || tInfo.getType() == eActivityType.TreasureActivity.getValue() || tInfo.getType() == eActivityType.XiaYueActivity.getValue())) {
                    continue;
                }
                tempActivityInfoMap.remove(activityDetail.getActivityId());
            }
        }
        Map<Integer, List<ActivityConditionInfo>> tempConditionInfoMap = new ConcurrentHashMap<>();
        Map<Integer, ActivityInfo> tempDataMap = new ConcurrentHashMap<>();
        Map<Integer, Map<Integer, MallInfo>> tempActivityMallMap = new ConcurrentHashMap<>();
        Map<Integer, Map<String, ActivityConfig>> tempActivityConfigMap = new ConcurrentHashMap<>();
        for (ActivityInfo activityInfo : tempActivityInfoMap.values()) {
            List<ActivityConditionInfo> conditionInfoList = tempActivityConditionInfoMap.get(activityInfo.getActivityId());
            if (null != conditionInfoList) {
                tempConditionInfoMap.put(activityInfo.getActivityId(), conditionInfoList);
            }
            tempDataMap.put(activityInfo.getActivityId(), activityInfo);
            Map<Integer, MallInfo> tempMallMap = inActivityMallInfoMap.get(activityInfo.getActivityId());
            if (null != tempMallMap) {
                tempActivityMallMap.put(activityInfo.getActivityId(), tempMallMap);
            }
            //活动配置
            Map<String, ActivityConfig> tempConfigMap = inActivityConfigMap.get(activityInfo.getActivityId());
            if (null != tempConfigMap) {
                tempActivityConfigMap.put(activityInfo.getActivityId(), tempConfigMap);
            }
        }
        allActivityInfoMap = tempDataMap;
        activityConditionInfoMap = tempConditionInfoMap;
        allActivityMallInfoMap = tempActivityMallMap;
        activityConfigMap = tempActivityConfigMap;
        triggerRevisionMap.clear();
        checkNewActivity();
        logger.info("reload normal activity end");
    }

    private static void checkNewActivity(){
        logger.info("check new activity start");
        Map<Integer, ActivityInfo> inTimeActivityMap = new ConcurrentHashMap<>();
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (ActivityMgr.activityInLoadTime(activityInfo)) {
                inTimeActivityMap.put(activityInfo.getActivityId(), activityInfo);
            }
        }
        showTimeActivityInfoMap = inTimeActivityMap;
        GeneralActivityRankMgr.reloadRank();

        playerReloadActivity();
        RankMgr.reloadActivityRank();
        UnionActivityMgr.reloadActivityData(showTimeActivityInfoMap);
        ActivityRankMgr.reloadActivityRank();
        logger.info("check new activity end");
    }

    private static void addActivityDetail(int activityId) {
        synchronized (activityDetailMap) {
            if (!activityDetailMap.containsKey(activityId)) {
                ActivityDetail activityDetail = new ActivityDetail();
                activityDetail.setActivityId(activityId);
                activityDetail.setAutoSendRewardState(0);
                activityDetail.setInsertOption();
                activityDetailMap.put(activityDetail.getActivityId(), activityDetail);
            }
        }
    }

    private static Map<Integer, ActivityDetail> getCopyActivityDetailMap() {
        return new ConcurrentHashMap<>(activityDetailMap);
    }

    /**
     * 要补发的活动类型放在这加 方法名有问题
     */

    public static void recordRankActivity() {
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (ActivityMgr.activityInRecordTime(activityInfo)) {
                if (!activityDetailMap.containsKey(activityInfo.getActivityId()) && (activityInfo.getType() == eActivityType.RankActivity.getValue() ||
                        activityInfo.getType() == eActivityType.UnionRankActivity.getValue() ||
                        activityInfo.getType() == eActivityType.CrossHolidayActivity.getValue() ||
                        activityInfo.getType() == eActivityType.TreasureActivity.getValue() ||
                        activityInfo.getType() == eActivityType.ShuiHuActivity.getValue() ||
                        activityInfo.getType() == eActivityType.TrystActivity.getValue() ||
                        activityInfo.getType() == eActivityType.BusyFarmingActivity.getValue() ||
                        activityInfo.getType() == eActivityType.GuGuoXunBaoActivity.getValue() ||
                        activityInfo.getType() == eActivityType.XiaYueActivity.getValue() ||
                        activityInfo.getType() == eActivityType.LanRuoSiActivity.getValue() ||
                        activityInfo.getType() == eActivityType.GourdChildActivity.getValue() ||
                        activityInfo.getType() == eActivityType.WinterLoveActivity.getValue() ||
                        activityInfo.getType() == eActivityType.HellActivity.getValue()||
                        activityInfo.getType() ==eActivityType.XiaowuRecallActivity.getValue() ||
                        activityInfo.getType() == eActivityType.DouLuoShrekActivity.getValue()||
                        (activityInfo.getType() == eActivityType.NewRechargeActivity.getValue() && activityInfo.getChildType() == eNewRechargeActivityType.WealthGodGifts.getValue())||
                        activityInfo.getType() == eActivityType.OldPlayerReturn.getValue() ||
                        activityInfo.getType() == eActivityType.XiaoyuCostumeActivity.getValue()||
                        activityInfo.getType() == eActivityType.ShuiHuYeZiCardActivity.getValue() ||
                        activityInfo.getType() == eActivityType.SeacraftActivity.getValue() ||
                        activityInfo.getType() == eActivityType.SpringDinner.getValue()||
                        activityInfo.getType() == eActivityType.ToyHouse.getValue()||
                        activityInfo.getType() == eActivityType.ChineseChess.getValue()||
                        activityInfo.getType() == eActivityType.ShuShanActivity.getValue() ||
                        activityInfo.getType() == eActivityType.TongBingActivity.getValue()||
                        activityInfo.getType() == eActivityType.TonBingActivity.getValue()||
                        activityInfo.getType() == eActivityType.ChannelTonBingActivity.getValue()||
                        activityInfo.getType() == eActivityType.ChuHanZB.getValue() ||
                        activityInfo.getType() == eActivityType.ClimbTower.getValue() ||
                        activityInfo.getType() == eActivityType.OperaMask.getValue()||
                        activityInfo.getType() == eActivityType.RankUnionWar.getValue() ||
                        activityInfo.getType() == eActivityType.FellingTrees.getValue() ||
                        activityInfo.getType() == eActivityType.Pasture.getValue() ||
                        activityInfo.getType() == eActivityType.Tomb.getValue() ||
                        activityInfo.getType() == eActivityType.GreatTradeActivity.getValue() ||
                        activityInfo.getType() == eActivityType.Twins.getValue() ||
                        activityInfo.getType() == eActivityType.CricketSeasonActivity.getValue() ||
                        activityInfo.getType() == eActivityType.Cat.getValue() ||
                        activityInfo.getType() == eActivityType.WorldCup.getValue() ||
                        activityInfo.getType() == eActivityType.CarpTripActivity.getValue() ||
                        activityInfo.getType() == eActivityType.FireWork2023.getValue() ||
                        activityInfo.getType() == eActivityType.CommonWishDraw.getValue() ||
                        activityInfo.getType() == eActivityType.XiuXian.getValue() ||
                        activityInfo.getType() == eActivityType.Feast.getValue() ||
                        activityInfo.getType() == eActivityType.JieShi.getValue() ||
                        activityInfo.getType() == eActivityType.GoddessActivity.getValue() ||
                        activityInfo.getType() == eActivityType.CrossPasture.getValue() ||
                        activityInfo.getType() == eActivityType.AreaWashePkActivity.getValue() ||
                        activityInfo.getType() == eActivityType.PeakSeacraftActivity.getValue()||
                        activityInfo.getType() == eActivityType.PeerlessBeautyLotteryActivity.getValue() ||
                        activityInfo.getType() == eActivityType.DeepFishing.getValue() ||
                        activityInfo.getType() == eActivityType.FiveHero.getValue() ||
                        activityInfo.getType() == eActivityType.LangYaBang.getValue() ||
                        activityInfo.getType() == eActivityType.LangYaMemorial.getValue() ||
                        activityInfo.getType() == eActivityType.SilkRoad.getValue() ||
                        activityInfo.getType() == eActivityType.Advertisement.getValue() ||
                        activityInfo.getType() == eActivityType.ZhouNianTurntable.getValue() ||
                        activityInfo.getType() == eActivityType.WanYao.getValue() ||
                        activityInfo.getType() == eActivityType.QiXiActivity.getValue() ||
                        activityInfo.getType() == eActivityType.GuaGiftsActivity.getValue() ||
                        (activityInfo.getType() == eActivityType.RechargeActivity.getValue() && (activityInfo.getChildType() == eActivityChargeType.TenDayDiscountRecharge.getChildType() || activityInfo.getChildType() == eActivityChargeType.TimeLimitCharge.getChildType())) ||
                        activityInfo.getType() == eActivityType.EveFeast.getValue() ||
                        activityInfo.getType() == eActivityType.DaoMu.getValue() ||
                        activityInfo.getType() == eActivityType.DigGold.getValue() ||
                        activityInfo.getType() == eActivityType.WitchDraw.getValue() ||
                        activityInfo.getType() == eActivityType.SteleSoul.getValue() ||
                        activityInfo.getType() == eActivityType.MusicRoomRank.getValue() ||
                        activityInfo.getType() == eActivityType.SnowGarden.getValue() ||
                        activityInfo.getType() == eActivityType.ActivityFund.getValue() ||
                        activityInfo.getType() == eActivityType.RuiShou.getValue() ||
                        activityInfo.getType() == eActivityType.SummerGames.getValue() ||
                        activityInfo.getType() == eActivityType.DoubleSpring.getValue() ||
                        activityInfo.getType() == eActivityType.PiXiu.getValue() ||
                        activityInfo.getType() == eActivityType.SpringUnionBanquet.getValue() ||
                        activityInfo.getType() == eActivityType.ZhenHuan.getValue() ||
                        activityInfo.getType() == eActivityType.BiaoJu.getValue() ||
                        activityInfo.getType() == eActivityType.SuiTang.getValue() ||
                        activityInfo.getType() == eActivityType.BusinessDepart.getValue()||
                        activityInfo.getType() == eActivityType.FoxCard.getValue() ||
                        activityInfo.getType() == eActivityType.Harps.getValue() ||
                        activityInfo.getType() == eActivityType.SonHai.getValue() ||
                        activityInfo.getType() == eActivityType.SuoYaoActivity.getValue() ||
                        activityInfo.getType() == eActivityType.XingYouShanShui.getValue() ||
                        activityInfo.getType() == eActivityType.HsIsland.getValue() ||
                        activityInfo.getType() == eActivityType.Turtle.getValue() ||
                        activityInfo.getType() == eActivityType.HorseRun.getValue() ||
                        activityInfo.getType() == eActivityType.HotpotJump.getValue() ||
                        activityInfo.getType() == eActivityType.Gashapon.getValue() ||
                        activityInfo.getType() == eActivityType.GoldIngotFund.getValue() ||
                        activityInfo.getType() == eActivityType.StarLight.getValue() ||
                        activityInfo.getType() == eActivityType.Apprentice.getValue() ||
                        (activityInfo.getType() == eActivityType.ChefDuel.getValue() && activityInfo.getChildType() == eChefDuelActivityType.Phase1.getChildType()) ||
                        activityInfo.getType() == eActivityType.YQHotel.getValue() ||
                        activityInfo.getType() == eActivityType.IceServerGift.getValue()
                )) {
                    addActivityDetail(activityInfo.getActivityId());
                }
            }
        }
    }

    public static void checkAutoSendActivityReward() {
        Map<Integer, ActivityInfo> overTimeActivityMap = new ConcurrentHashMap<>();
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (activityInfo.getType() == eActivityType.CrossHolidayActivity.getValue() ||
                    activityInfo.getType() == eActivityType.TreasureActivity.getValue() ||
                    activityInfo.getType() == eActivityType.XiaYueActivity.getValue()) {  //灵猫活动需要领奖期就开始补发奖励
                if (ActivityMgr.activityOverEndTime(activityInfo)) {
                    overTimeActivityMap.put(activityInfo.getActivityId(), activityInfo);
                }
            } else if (ActivityMgr.activityOverTime(activityInfo) && (activityInfo.getType() == eActivityType.RankActivity.getValue() ||
                    activityInfo.getType() == eActivityType.UnionRankActivity.getValue() ||
                    activityInfo.getType() == eActivityType.ShuiHuActivity.getValue() ||
                    activityInfo.getType() == eActivityType.TrystActivity.getValue() ||
                    activityInfo.getType() == eActivityType.BusyFarmingActivity.getValue() ||
                    activityInfo.getType() == eActivityType.GuGuoXunBaoActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CrossDunHuangShiKuActivity.getValue() ||
                    activityInfo.getType() == eActivityType.LanRuoSiActivity.getValue() ||
                    (activityInfo.getType() == eActivityType.GourdChildActivity.getValue()) ||
                    activityInfo.getType() == eActivityType.WinterLoveActivity.getValue() ||
                    activityInfo.getType() == eActivityType.HellActivity.getValue()||
                    activityInfo.getType() == eActivityType.XiaowuRecallActivity.getValue()||
                    activityInfo.getType() == eActivityType.DouLuoShrekActivity.getValue()||
                    activityInfo.getType() == eActivityType.OldPlayerReturn.getValue() ||
                    activityInfo.getType() == eActivityType.XiaoyuCostumeActivity.getValue() ||
                    activityInfo.getType() == eActivityType.ShuiHuYeZiCardActivity.getValue()||
                    activityInfo.getType() == eActivityType.SeacraftActivity.getValue() ||
                    activityInfo.getType() == eActivityType.SpringDinner.getValue()||
                    activityInfo.getType() == eActivityType.ToyHouse.getValue()||
                    activityInfo.getType() == eActivityType.ChineseChess.getValue() ||
                    activityInfo.getType() == eActivityType.ShuShanActivity.getValue() ||
                    activityInfo.getType() == eActivityType.TongBingActivity.getValue() ||
                    activityInfo.getType() == eActivityType.TonBingActivity.getValue() ||
                    activityInfo.getType() == eActivityType.ChannelTonBingActivity.getValue() ||
                    activityInfo.getType() == eActivityType.ChuHanZB.getValue() ||
                    activityInfo.getType() == eActivityType.ClimbTower.getValue() ||
                    activityInfo.getType() == eActivityType.OperaMask.getValue() ||
                    activityInfo.getType() == eActivityType.RankUnionWar.getValue() ||
                    activityInfo.getType() == eActivityType.FellingTrees.getValue() ||
                    activityInfo.getType() == eActivityType.Pasture.getValue() ||
                    activityInfo.getType() == eActivityType.Tomb.getValue() ||
                    activityInfo.getType() == eActivityType.GreatTradeActivity.getValue() ||
                    activityInfo.getType() == eActivityType.Twins.getValue() ||
                    activityInfo.getType() == eActivityType.CricketSeasonActivity.getValue() ||
                    activityInfo.getType() == eActivityType.Cat.getValue() ||
                    activityInfo.getType() == eActivityType.WorldCup.getValue() ||
                    activityInfo.getType() == eActivityType.CarpTripActivity.getValue() ||
                    activityInfo.getType() == eActivityType.FireWork2023.getValue() ||
                    activityInfo.getType() == eActivityType.XiuXian.getValue() ||
                    activityInfo.getType() == eActivityType.Feast.getValue() ||
                    activityInfo.getType() == eActivityType.JieShi.getValue() ||
                    activityInfo.getType() == eActivityType.GoddessActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CommonWishDraw.getValue() ||
                    activityInfo.getType() == eActivityType.CrossPasture.getValue() ||
                    activityInfo.getType() == eActivityType.AreaWashePkActivity.getValue() ||
                    activityInfo.getType() == eActivityType.PeakSeacraftActivity.getValue()||
                    activityInfo.getType() == eActivityType.PeerlessBeautyLotteryActivity.getValue()||
                    activityInfo.getType() == eActivityType.DeepFishing.getValue()||
                    activityInfo.getType() == eActivityType.FiveHero.getValue() ||
                    activityInfo.getType() == eActivityType.LangYaBang.getValue() ||
                    activityInfo.getType() == eActivityType.LangYaMemorial.getValue() ||
                    activityInfo.getType() == eActivityType.SilkRoad.getValue() ||
                    activityInfo.getType() == eActivityType.Advertisement.getValue() ||
                    activityInfo.getType() == eActivityType.ZhouNianTurntable.getValue() ||
                    activityInfo.getType() == eActivityType.WanYao.getValue() ||
                    activityInfo.getType() == eActivityType.QiXiActivity.getValue() ||
                    activityInfo.getType() == eActivityType.GuaGiftsActivity.getValue() ||
                    (activityInfo.getType() == eActivityType.RechargeActivity.getValue() && (activityInfo.getChildType() == eActivityChargeType.TenDayDiscountRecharge.getChildType() || activityInfo.getChildType() == eActivityChargeType.TimeLimitCharge.getChildType())) ||
                    activityInfo.getType() == eActivityType.EveFeast.getValue() ||
                    activityInfo.getType() == eActivityType.DaoMu.getValue() ||
                    activityInfo.getType() == eActivityType.DigGold.getValue() ||
                    activityInfo.getType() == eActivityType.WitchDraw.getValue() ||
                    activityInfo.getType() == eActivityType.SteleSoul.getValue() ||
                    activityInfo.getType() == eActivityType.MusicRoomRank.getValue() ||
                    activityInfo.getType() == eActivityType.SnowGarden.getValue() ||
                    activityInfo.getType() == eActivityType.ActivityFund.getValue() ||
                    activityInfo.getType() == eActivityType.RuiShou.getValue() ||
                    activityInfo.getType() == eActivityType.SummerGames.getValue() ||
                    activityInfo.getType() == eActivityType.DoubleSpring.getValue() ||
                    activityInfo.getType() == eActivityType.PiXiu.getValue() ||
                    activityInfo.getType() == eActivityType.SpringUnionBanquet.getValue() ||
                    activityInfo.getType() == eActivityType.ZhenHuan.getValue() ||
                    activityInfo.getType() == eActivityType.BiaoJu.getValue() ||
                    activityInfo.getType() == eActivityType.SuiTang.getValue() ||
                    activityInfo.getType() == eActivityType.BusinessDepart.getValue() ||
                    activityInfo.getType() == eActivityType.FoxCard.getValue() ||
                    activityInfo.getType() == eActivityType.Harps.getValue() ||
                    activityInfo.getType() == eActivityType.SonHai.getValue() ||
                    activityInfo.getType() == eActivityType.SuoYaoActivity.getValue() ||
                    activityInfo.getType() == eActivityType.XingYouShanShui.getValue() ||
                    activityInfo.getType() == eActivityType.HsIsland.getValue() ||
                    activityInfo.getType() == eActivityType.Turtle.getValue() ||
                    activityInfo.getType() == eActivityType.HorseRun.getValue() ||
                    activityInfo.getType() == eActivityType.HotpotJump.getValue() ||
                    activityInfo.getType() == eActivityType.Gashapon.getValue() ||
                    activityInfo.getType() == eActivityType.GoldIngotFund.getValue() ||
                    activityInfo.getType() == eActivityType.StarLight.getValue() ||
                    activityInfo.getType() == eActivityType.Apprentice.getValue() ||
                    (activityInfo.getType() == eActivityType.ChefDuel.getValue() && activityInfo.getChildType() == eChefDuelActivityType.Phase1.getChildType()) || //厨神争霸一阶段用通用的
                    activityInfo.getType() == eActivityType.YQHotel.getValue() ||
                    activityInfo.getType() == eActivityType.IceServerGift.getValue()
            )) {
                overTimeActivityMap.put(activityInfo.getActivityId(), activityInfo);
            } else if (ActivityMgr.activityOverTime(activityInfo) && activityInfo.getType() == eActivityType.NewRechargeActivity.getValue()) {
                overTimeActivityMap.put(activityInfo.getActivityId(), activityInfo);
            }
        }
        Map<Integer, ActivityDetail> copyMap = getCopyActivityDetailMap();
        for (ActivityDetail activityDetail : copyMap.values()) {
            if (activityDetail.getAutoSendRewardState() == 1) {//已经发放过
                continue;
            }
            ActivityInfo activityInfo = overTimeActivityMap.get(activityDetail.getActivityId());
            if (null == activityInfo) {//没找到活动信息
                continue;
            }
            if (activityInfo.getType() == eActivityType.RankActivity.getValue()) {
                autoSendActivityReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.UnionRankActivity.getValue()) {
                autoSendUnionActivityReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.CrossHolidayActivity.getValue()) {
                autoSendHolidayActivityReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.TreasureActivity.getValue()) {
                autoSendTreasureActivityReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.ShuiHuActivity.getValue()) {
                autoSendShuiHuActivityReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.TrystActivity.getValue()) {
                autoSendTrystActivityReward(activityDetail, activityInfo);
            } else if(activityInfo.getType() == eActivityType.BusyFarmingActivity.getValue()){
                autoSendActivityReward(activityDetail, activityInfo, eGamePlayerEventType.BusyFarmingGrade.getValue(),
                        MailManager.BUSY_FARMING_ACTIVITY_ACHIEVEMENT_REWARD_TITLE, MailManager.BUSY_FARMING_ACTIVITY_ACHIEVEMENT_REWARD_CONTENT);
            } else if(activityInfo.getType() == eActivityType.GuGuoXunBaoActivity.getValue()){
                autoSendActivityReward(activityDetail, activityInfo, eGamePlayerEventType.GuGuoXunBaoTreasureValue.getValue(),
                        MailManager.GUGUOXUNBAO_ACTIVITY_REWARD_TITLE, MailManager.GUGUOXUNBAO_ACTIVITY_REWARD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.XiaYueActivity.getValue()) {
                autoSendXiaYueCombReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.LanRuoSiActivity.getValue()){
                autoSendLanRuoSiReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.GourdChildActivity.getValue() && activityInfo.getChildType() == GourdPlantMgr.ACTIVITY_CHILD_TYPE){
                autoSendActivityReward(activityDetail, activityInfo, eGamePlayerEventType.GourdPlantKeepsakeNum.getValue(),
                        MailManager.GOURD_PLANT_ACTIVITY_ACHIEVEMENT_REWARD_TITLE, MailManager.GOURD_PLANT_ACTIVITY_ACHIEVEMENT_REWARD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.GourdChildActivity.getValue() && activityInfo.getChildType() == GourdChildMgr.ACTIVITY_CHILD_TYPE){
                ArrayList<Integer> list = new ArrayList<>(2);
                list.add(eGamePlayerEventType.GourdChildPassTotalStar.getValue());
                list.add(eGamePlayerEventType.GourdChildLotusLv.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.GoddessActivity.getValue()){
                ArrayList<Integer> list = new ArrayList<>(3);
                list.add(eGamePlayerEventType.GoddessPeoUnlock.getValue());
                list.add(eGamePlayerEventType.GoddessPeoCombProgress.getValue());
                list.add(eGamePlayerEventType.GoddessMissionProgress.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.WinterLoveActivity.getValue()) {
                autoSendWinterLoveCombReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.PiXiu.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.PiXiuHappyValue.getValue());
                list.add(eGamePlayerEventType.SpringBanquetVip.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            }else if(activityInfo.getType() == eActivityType.HellActivity.getValue()){
                autoSendActivityReward(activityDetail, activityInfo, eGamePlayerEventType.HellActivityScore.getValue(),
                        MailManager.HELL_ACTIVITY_REWARD_TITLE, MailManager.HELL_ACTIVITY_REWARD_CONTENT);
            }else if (activityInfo.getType()==eActivityType.XiaowuRecallActivity.getValue()){
                autoSendXiaowuActivityReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.OldPlayerReturn.getValue()) {
                //autoSendOldPlayerReturnActivityReward(activityDetail,activityInfo);       策划说不补发 并且老活动不过期 所以不补发了
            }else if(activityInfo.getType() == eActivityType.DouLuoShrekActivity.getValue()){
                if (activityInfo.getChildType() == 1) {
                    //斗罗大陆学院没有自动发奖的
                    autoSendActivityReward(activityDetail, activityInfo, eGamePlayerEventType.DouLuoShrekActivityLevelUpBuilding.getValue(),
                            MailManager.SHREK_ACTIVITY_REWARD_TITLE, MailManager.SHREK_ACTIVITY_REWARD_CONTENT);
                }
                if (activityInfo.getChildType() == 2) {
                    //恶人谷没有自动发奖的
                    autoSendActivityReward(activityDetail, activityInfo, eGamePlayerEventType.DouLuoShrekActivityLevelUpBuilding2.getValue(),
                            MailManager.VILLAINVALLEY_ACTIVITY_REWARD_TITLE, MailManager.VILLAINVALLEY_ACTIVITY_REWARD_CONTENT);
                }
            } else if(activityInfo.getType() == eActivityType.ShuiHuYeZiCardActivity.getValue()){
                autoSendShuiHuYeZiCardReward(activityDetail, activityInfo);
            }else if(activityInfo.getType() == eActivityType.SpringDinner.getValue()){
                //没有
            } else if(activityInfo.getType() == eActivityType.ChineseChess.getValue()){
                //没有
                autoSendChineseChessReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.NewRechargeActivity.getValue() && activityInfo.getChildType() == eNewRechargeActivityType.WealthGodGifts.getValue()) {
                autoSendWealthGodGiftReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.XiaoyuCostumeActivity.getValue()) {
                //小玉服装自动发奖
                autoSendXiaoyuCostumeActivityReward(activityDetail, activityInfo);
            } else if(activityInfo.getType() == eActivityType.SeacraftActivity.getValue()) {
                autoSendSeacraftSouthSeaReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.ToyHouse.getValue()) {
                autoSendToyHouseAllReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.ShuShanActivity.getValue()) {
                autoSendShuShanReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.TongBingActivity.getValue()) {
                autoSendTongBingReward(activityDetail, activityInfo);
            }else if (activityInfo.getType() == eActivityType.TonBingActivity.getValue()) {
                autoSendTonBingReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.ChannelTonBingActivity.getValue()) {
                autoSendChannelTonBingReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.ChuHanZB.getValue()) {
                List<Integer> typeList = new ArrayList<>();
                typeList.add(eGamePlayerEventType.ChuHanZhanGong.getValue());
                typeList.add(eGamePlayerEventType.ChuHanUnionZhanGong.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.SuiTang.getValue()) {
                autoSendSuiTangReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.Harps.getValue()) {
                autoSendHarpsReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.ClimbTower.getValue()){
                autoSendClimbTowerReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.OperaMask.getValue()) {
                autoSendOperaMaskReward(activityDetail, activityInfo);
            }else if (activityInfo.getType() == eActivityType.RankUnionWar.getValue()) {
                autoSendRankUnionWarReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.FellingTrees.getValue()) {
                autoSendFellingTreesReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.Pasture.getValue()) {
                autoSendPastureReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.Tomb.getValue()){
                autoSendTombActivityReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.GreatTradeActivity.getValue()){
                autoSendGreatTradeActivityReward(activityDetail, activityInfo);
                autoSendGreatTradeActivityReward2(activityDetail, activityInfo);
            }else if (activityInfo.getType() == eActivityType.Twins.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(2);
                list.add(eGamePlayerEventType.TwinsKangfuComb.getValue());
                list.add(eGamePlayerEventType.TwinsKangfuAllLevel.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.CricketSeasonActivity.getValue()) {
                autoSendCricketActivityConditionReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.Cat.getValue()){
                autoSendCatActivityReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.WorldCup.getValue()){
                autoSendWorldCupReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.PeakStrongHold.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(2);
                list.add(eGamePlayerEventType.PeakStrongHoldGuessWin.getValue());
                list.add(eGamePlayerEventType.PeakStrongHoldGuessChampion.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.CarpTripActivity.getValue()){
                autoSendCarpTripActivityReward(activityDetail,activityInfo);
                autoSendCarpTripActivityReward2(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.XiuXian.getValue()){
                autoSendXiuXianActivityReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.Feast.getValue()){
                autoSendShanHeFeastActivityReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.JieShi.getValue()){
                autoSendJieShiActivityReward(activityDetail,activityInfo);
            } else if (activityInfo.getType() == eActivityType.FireWork2023.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(3);
                list.add(eGamePlayerEventType.FireWorkHappyValue.getValue());
                list.add(eGamePlayerEventType.FireWorkSpGetCount.getValue());
                list.add(eGamePlayerEventType.FireWorkSpUseCount.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if(activityInfo.getType() == eActivityType.PeakSeacraftActivity.getValue()) {
                autoSendPeakSeacraftReward(activityDetail, activityInfo);
            } else if(activityInfo.getType() == eActivityType.CrossPasture.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.ChannelPastureMaxScoreAchieve.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if(activityInfo.getType() == eActivityType.AreaWashePkActivity.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.WaShePkUserScoreArchive.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.GoddessActivity.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(3);
                list.add(eGamePlayerEventType.GoddessPeoCombProgress.getValue());
                list.add(eGamePlayerEventType.GoddessPeoUnlock.getValue());
                list.add(eGamePlayerEventType.GoddessMissionProgress.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if(activityInfo.getType() == eActivityType.CommonWishDraw.getValue()){
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.CommonWishTotalDraw.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.DeepFishing.getValue()){
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.DeepFishingTotalCoinProcess.getValue());
                list.add(eGamePlayerEventType.DeepFishingUnlockItem.getValue());
                list.add(eGamePlayerEventType.DeepFishingUnlockFish.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo,list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.FiveHero.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.FiveHeroPopularity.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.LangYaBang.getValue()){
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.LangYaBuildingLevelCondition.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo,list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.LangYaMemorial.getValue()){
                ArrayList<Integer> list = new ArrayList<>(2);
                list.add(eGamePlayerEventType.LangYaMemorialBuildAllValue.getValue());
                list.add(eGamePlayerEventType.LangYaMemorialBuildTimes.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.SilkRoad.getValue()) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.SilkRoadReliceAchieve.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo,list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.Advertisement.getValue()){
                ArrayList<Integer> list = new ArrayList<>(2);
                list.add(eGamePlayerEventType.TotalWatchAdvertisementTimeCondition.getValue());
                list.add(eGamePlayerEventType.AdvertisementDailyResetCondition.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.FlowerStudy.getValue()){
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.FlowerStudyQACondition.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.ZhouNianTurntable.getValue()) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.ZhouNianTurntableTimes.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo,list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.WanYao.getValue()){
                ArrayList<Integer> list = new ArrayList<>(2);
                list.add(eGamePlayerEventType.WanYaoMissionProgress.getValue());
                list.add(eGamePlayerEventType.WanYaoAddMonsterCondition.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.QiXiActivity.getValue()) {
                autoSendQixiGiftReward(activityDetail, activityInfo);
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.QixiSendFlowerAchieve.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.GuaGiftsActivity.getValue()) {
                autoSendGuaGiftReward(activityDetail, activityInfo);
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.GuaGiftsSendNobleGift.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.DigGold.getValue()){
                ArrayList<Integer> list = new ArrayList<>(2);
                list.add(eGamePlayerEventType.DigGoldAntiqueCondition.getValue());
                list.add(eGamePlayerEventType.DigGoldAntiqueScoreCondition.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.RechargeActivity.getValue() && activityInfo.getChildType() == eActivityChargeType.TenDayDiscountRecharge.getChildType()){
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.TenDayDiscount.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.RechargeActivity.getValue() && activityInfo.getChildType() == eActivityChargeType.TimeLimitCharge.getChildType()){
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.RechargeVipExpDay.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.EveFeast.getValue()) {

                autoSendEveFeastGameSettleReward(activityInfo);

                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.EveFeastInvite.getValue());
                list.add(eGamePlayerEventType.EveFeastInvite2.getValue());
                list.add(eGamePlayerEventType.EveFeastInvite3.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.DaoMu.getValue()) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.DaoMuAchievementCollectionScore.getValue());
                // 盗墓pvp经验成就不补发,改成要补发了
                list.add(eGamePlayerEventType.DaoMuPvpExp.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.WitchDraw.getValue()) {
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.WitchDrawScoreCondition.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.SteleSoul.getValue()) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.SteleSoulRoundCount.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.MusicRoomRank.getValue()) {
//                autoSendMusicRoomRankShowReward(activityInfo);
            } else if (activityInfo.getType() == eActivityType.SnowGarden.getValue()) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.SnowGardenVisitCount.getValue());
                list.add(eGamePlayerEventType.SnowGardenBuildingLevel.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.ActivityFund.getValue()){
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.CommonActivityFundProgress.getValue());
                String mailTitle = MailManager.FUND_EXPIRE_MAIL_TITLE;
                String mailContent = MailManager.FUND_EXPIRE_MAIL_CONTENT;
                if (activityInfo.getChildType() == 1) {
                    mailTitle = MailManager.SNOW_GARDEN_MAIL_TITLE_1_1;
                    mailContent = MailManager.SNOW_GARDEN_MAIL_CONTENT_1_1;
                } else if (activityInfo.getChildType() == 2){
                    mailTitle = MailManager.SNOW_GARDEN_MAIL_TITLE_1_2;
                    mailContent = MailManager.SNOW_GARDEN_MAIL_CONTENT_1_2;
                }else if(activityInfo.getChildType() == 3){
                    mailTitle = MailManager.SUMMER_GAMES_MAIL_TITLE_1;
                    mailContent = MailManager.SUMMER_GAMES_CONTENT_1;
                }
                autoSendActivityProcessReward(activityDetail, activityInfo, list, mailTitle, mailContent);
            } else if (activityInfo.getType() == eActivityType.RuiShou.getValue()){
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.RuiShouCostNum.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.SummerGames.getValue()){
                ArrayList<Integer> list = new ArrayList<>(1);
                list.add(eGamePlayerEventType.SummerGamesEntryScoreArchive.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            }  else if (activityInfo.getType() == eActivityType.XingYouShanShui.getValue()){
                ArrayList<Integer> list = new ArrayList<>(1);
//                list.add(eGamePlayerEventType.XingYouShanShuiUserDiceCount.getValue());
                list.add(eGamePlayerEventType.XingYouShanShuiUserRoundCount.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            }  else if (activityInfo.getType() == eActivityType.DoubleSpring.getValue()){
                //踏春游记活动-奖励补发
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.DoubleSpringZl.getValue());
                list.add(eGamePlayerEventType.DoubleSpringScore.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.ZhenHuan.getValue()) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.ZhenHuanFirstProcessUnlockStoryNum.getValue());
                list.add(eGamePlayerEventType.ZhenHuanThirdProcessBanquetTimes.getValue());
                list.add(eGamePlayerEventType.ZhenHuanSecondProcessLoveDegree.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);

//                autoSendZhenHuanSecondKickBackReward(activityInfo);

                autoSendZhenHuanSecondJoinPartyReward(activityInfo);
            } else if (activityInfo.getType() == eActivityType.BiaoJu.getValue()) {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.BiaoJuExp.getValue());
                list.add(eGamePlayerEventType.BiaoJuUnionExpAdd.getValue());
                list.add(eGamePlayerEventType.CommonActivityFundProgress.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            }  else if (activityInfo.getType() == eActivityType.BusinessDepart.getValue()){
                //商途启程-奖励补发
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.BusinessDepartCostScoreTask.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.FoxCard.getValue()) {
                List<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.FoxCardTreeScore.getValue());
                list.add(eGamePlayerEventType.FoxCardUnlockCard.getValue());
                list.add(eGamePlayerEventType.FoxCardOneCardUnlock.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.SonHai.getValue()){
                //山海伏兽-个人成就补发
                ArrayList<Integer> list = new ArrayList<>();
//                list.add(eGamePlayerEventType.SonHaiAchievement.getValue());
                list.add(eGamePlayerEventType.CommonActivityFundProgress.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.SuoYaoActivity.getValue()){

                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.SuoYaoExploreItemUse.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.HsIsland.getValue()){
                //海神岛-【个人成就】，【商会成就】,【基金】补发
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.HsIslandUserAchievement.getValue());
                list.add(eGamePlayerEventType.HsIslandUnionAchievement.getValue());
                list.add(eGamePlayerEventType.CommonActivityFundProgress.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.Apprentice.getValue()) {
                //爱徒养成-【个人成就】,【基金】补发
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.ApprenticeScoreAchievement.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.HorseRun.getValue()){
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.HorseRunUnionScoreAchievement.getValue());
                list.add(eGamePlayerEventType.HorseRunPersonalGradeAchievement.getValue());
                list.add(eGamePlayerEventType.CommonActivityFundProgress.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.HotpotJump.getValue()) {
                List<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.CommonActivityFundProgress.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            }  else if (activityInfo.getType() == eActivityType.Gashapon.getValue()){
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.GashaponIngotRebate.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.GASHAPON_INGOT_REBATE_CONTENT);
            } else if (activityInfo.getType() == eActivityType.GoldIngotFund.getValue()) {
                GoldIngotFundMgr.autoSendReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.StarLight.getValue()) {
                autoSendStarLightReward(activityDetail, activityInfo);
            } else if (activityInfo.getType() == eActivityType.ChefDuel.getValue() && activityInfo.getChildType() == eChefDuelActivityType.Phase1.getChildType()){ //厨神争霸一阶段用通用的
                ArrayList<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.ChefDuel1ScoreCondition.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list,
                        MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            } else if (activityInfo.getType() == eActivityType.YQHotel.getValue()){
                List<Integer> list = new ArrayList<>();
                list.add(eGamePlayerEventType.YQHotelBuildingLevelUpTime.getValue());
                autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
            }
        }
    }

    /**
     * 星星点灯商城补发
     *
     * @param activityDetail 补发详情
     * @param activityInfo   activityInfo
     */
    private static void autoSendStarLightReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 确保用户数据入库
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }

        int activityId = activityInfo.getActivityId();
        boolean isAllSend = true;
        // 仅补发检测时调用一次数据库，不占用内存
        List<StarLightMallRecord> records = StarLightBusiness.getMallRecordsByType(activityId, 0);

        Map<Long, List<StarLightMallRecord>> userRecordMap = new HashMap<>(); // 玩家 -> 商品记录)
        Map<Integer, Map<Integer, MallInfo>> allActivityMallInfoMap = ActivityMgr.getAllActivityMallInfoMap();
        Map<Integer, MallInfo> mallInfoMap = allActivityMallInfoMap.get(activityId);

        for (StarLightMallRecord record : records) { // 分用户
            long userId = record.getUserId();
            if (!userRecordMap.containsKey(userId)) {
                userRecordMap.put(userId, new ArrayList<>());
            }
            userRecordMap.get(userId).add(record);
        }

        // 不论什么补发，最后都要再重新检查发放一遍，并结束这个活动的补发行为
        for (Map.Entry<Long, List<StarLightMallRecord>> kv : userRecordMap.entrySet()) {
            isAllSend = autoSend(kv.getValue(), kv.getKey(), activityInfo, mallInfoMap);
        }

        if (isAllSend) {
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 星星点灯发邮件
     *
     * @param records      商城补发记录
     * @param userId       用户ID
     * @param activityInfo activityInfo
     * @param mallInfoMap  mallInfoMap
     * @return 是否全部补发
     */
    private static boolean autoSend(List<StarLightMallRecord> records, long userId, ActivityInfo activityInfo,
                                    Map<Integer, MallInfo> mallInfoMap) {
        Property reward = new Property();

        if (records.isEmpty()) { // 没事别发邮件
            return true;
        }

        boolean isAllSend = true; // 当前玩家是否全部补发成功
        for (StarLightMallRecord record : records) {
            record.setAcquireType(2);
            record.setAcquireTime(System.currentTimeMillis());
            if (!StarLightBusiness.updateMallRecord(record)) {
                logger.error("auto send activity reward save db fail, activityId:{}, userId:{}," +
                                "activityDay:{}, mallId:{}", record.getActivityId(), record.getUserId(),
                        record.getActivityDay(), record.getMallId());
                isAllSend = false;
            } else {
                reward.addProperty(PropertyHelper.parseStringToProperty(mallInfoMap.get(record.getMallId()).getReward()));
            }
        }

        // 通用补发
        UserInfo userInfo = UserMgr.getUserInfo(userId);
        String language = LanguageType.LANGUAGE_DEFAULT;
        if (null != userInfo) {
            language = userInfo.getLanguage();
        }
        String activityName = ServerLanguageMgr.getContent(activityInfo.getActivityName(), language);
        String mailTitle =
                StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_TITLE,
                 language), activityName);
        String mailContent =
         StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_CONTENT,
          language), activityName);
        MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), reward.toHelperString(), mailContent, mailTitle);

        return isAllSend;
    }

    /**
     * 寒冬馈赠发邮件
     *
     * @param records      商城补发记录
     * @param userId       用户ID
     * @param activityInfo activityInfo
     * @return 是否全部补发
     */
    public static boolean autoSendIceServerGift(List<IceServerGiftMallRecord> records, long userId, ActivityInfo activityInfo) {
        Property reward = new Property();

        if (records.isEmpty()) { // 没事别发邮件
            return true;
        }
        Map<Integer, MallInfo> mallInfoMap = ActivityMgr.getAllActivityMallInfoMap().get(activityInfo.getActivityId());

        boolean isAllSend = true; // 当前玩家是否全部补发成功
        for (IceServerGiftMallRecord record : records) {
            record.setAcquireType(2);
            record.setAcquireTime(System.currentTimeMillis());
            if (!IceServerGiftBusiness.updateMallRecord(record)) {
                logger.error("auto send activity reward save db fail, activityId:{}, userId:{}," +
                                "activityDay:{}, mallId:{}", record.getActivityId(), record.getUserId(),
                        record.getActivityDay(), record.getMallId());
                isAllSend = false;
            } else {
                reward.addProperty(PropertyHelper.parseStringToProperty(mallInfoMap.get(record.getMallId()).getReward()));
            }
        }

        // 通用补发
        UserInfo userInfo = UserMgr.getUserInfo(userId);
        String language = LanguageType.LANGUAGE_DEFAULT;
        if (null != userInfo) {
            language = userInfo.getLanguage();
        }
        String activityName = ServerLanguageMgr.getContent(activityInfo.getActivityName(), language);
        String mailTitle =
                StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_TITLE,
                        language), activityName);
        String mailContent =
                StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_CONTENT,
                        language), activityName);
        MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), reward.toHelperString(), mailContent, mailTitle);

        return isAllSend;
    }


    /**
     * 甄嬛二阶段活动结束,玩家没领的被踢返还邀请函,要发邮件;改需求了，被踢不返还邀请函了
     *
     * @param activityInfo
     */
//    @Deprecated
//    private static void autoSendZhenHuanSecondKickBackReward(ActivityInfo activityInfo) {
//        if (activityInfo.getType() != eActivityType.ZhenHuan.getValue()) {
//            return;
//        }
//        if (activityInfo.getChildType() != eZhenHuanChildType.Second.getValue()) {
//            return;
//        }
//
//        List<UserZhenHuanKickData> kickDataList = new UserZhenHuanKickDaoImpl().getUserZhenHuanNeedAutoRewardKickDataList(activityInfo.getActivityId());
//
//        Map<Long, Property> userRewardMap = new HashMap<>();
//
//        for (UserZhenHuanKickData userZhenHuanKickData : kickDataList) {
//            userZhenHuanKickData.setConfirmTime(DateHelper.getCurrentTime());
//            if (new UserZhenHuanKickDaoImpl().update(userZhenHuanKickData)) {
//                Property reward = userRewardMap.get(userZhenHuanKickData.getUserId());
//                if (reward == null) {
//                    reward = new Property();
//                    userRewardMap.put(userZhenHuanKickData.getUserId(), reward);
//                }
//                reward.addProperty(PropertyHelper.parseStringToProperty(userZhenHuanKickData.getReward()));
//            }
//        }
//
//        for (Map.Entry<Long, Property> entry : userRewardMap.entrySet()) {
//            Long userId = entry.getKey();
//            Property reward = entry.getValue();
//            if (reward.isNothing()){
//                continue;
//            }
//
//            UserInfo userInfo = UserMgr.getUserInfo(userId);
//            String language = LanguageType.LANGUAGE_DEFAULT;
//            if (null != userInfo) {
//                language = userInfo.getLanguage();
//            }
//
//            String activityName = ServerLanguageMgr.getContent(activityInfo.getActivityName(), language);
//
//            String mailTitle = MessageFormat.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_TITLE, language), activityName);
//            String mailContent = MessageFormat.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_CONTENT, language), activityName);
//            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), reward.toHelperString(), mailContent, mailTitle);
//        }
//    }

    private static void autoSendZhenHuanSecondJoinPartyReward(ActivityInfo activityInfo) {
        if (activityInfo.getType() != eActivityType.ZhenHuan.getValue()) {
            return;
        }
        if (activityInfo.getChildType() != eZhenHuanChildType.Second.getValue()) {
            return;
        }
        Map<Long, Property> userRewardMap = new HashMap<>();
        List<UserZhenHuanPartyHistoryData> needAutoMailDataList = new UserZhenHuanPartyHistoryDaoImpl().getNeedAutoMailDataList(activityInfo.getActivityId());
        for (UserZhenHuanPartyHistoryData data : needAutoMailDataList) {
            data.setGetTime(DateHelper.getCurrentTime());
            if (new UserZhenHuanPartyHistoryDaoImpl().update(data)) {
                Property reward = userRewardMap.get(data.getUserId());
                if (reward == null) {
                    reward = new Property();
                    userRewardMap.put(data.getUserId(), reward);
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(data.getReward()));
            }
        }

        for (Map.Entry<Long, Property> entry : userRewardMap.entrySet()) {
            Long userId = entry.getKey();
            Property reward = entry.getValue();
            if (reward.isNothing()){
                continue;
            }

            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }

            String activityName = ServerLanguageMgr.getContent(activityInfo.getActivityName(), language);

            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_TITLE, language), activityName);
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_CONTENT, language), activityName);
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), reward.toHelperString(), mailContent, mailTitle);
        }

    }

    private static void autoSendCarpTripActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.CarpTripNormalCellPass.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    private static void autoSendCarpTripActivityReward2(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.CarpTripBigDrawProcess.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    private static void autoSendCatActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.CatActivitySwordLevel.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    private static void autoSendXiuXianActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.XiuXianAttackScore.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);

        typeList.clear();
        typeList.add(eGamePlayerEventType.XiuXianState.getValue());
        typeList.add(eGamePlayerEventType.XiuXianXianLi.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    private static void autoSendShanHeFeastActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.FeastPersonalScore.getValue());
        typeList.add(eGamePlayerEventType.FeastSectUseEnergyCount.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);

        typeList.clear();
        typeList.add(eGamePlayerEventType.FeastState.getValue());
        typeList.add(eGamePlayerEventType.FeastXianLi.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    private static void autoSendJieShiActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.JieShiTotalJiaoZi.getValue());
        typeList.add(eGamePlayerEventType.JieShiLevel.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    private static void autoSendGreatTradeActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.GreatTradeMerchant.getValue());
        typeList.add(eGamePlayerEventType.GreatTradeFate.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.GREAT_TRADE_MAIL_TITLE_PROGRESS_REWORD, MailManager.GREAT_TRADE_MAIL_CONTENT_PROGRESS_REWORD);
    }

    private static void autoSendGreatTradeActivityReward2(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.GreatTradeBronzeToken.getValue());
        typeList.add(eGamePlayerEventType.GreatTradeSliverToken.getValue());
        typeList.add(eGamePlayerEventType.GreatTradeGoldToken.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.GREAT_TRADE_MAIL_TITLE_PROGRESS_REWORD, MailManager.GREAT_TRADE_MAIL_CONTENT_PROGRESS_REWORD);
    }

    private static void autoSendClimbTowerReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.ClimbTowerBlueRuneAchievement.getValue());
        typeList.add(eGamePlayerEventType.ClimbTowerGreenRuneAchievement.getValue());
        typeList.add(eGamePlayerEventType.ClimbTowerOrangeRuneAchievement.getValue());
        typeList.add(eGamePlayerEventType.ClimbTowerPurpleRuneAchievement.getValue());
        if(activityInfo.getChildType() == 1) {
            autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.TONGTIAN_MAIL_TITLE_PROGRESS_REWORD, MailManager.TONGTIAN_MAIL_CONTENT_PROGRESS_REWORD);
        }else {
            autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.TIANGONG_MAIL_TITLE_PROGRESS_REWORD, MailManager.TIANGONG_MAIL_CONTENT_PROGRESS_REWORD);
        }
    }

    /**
     * 财神赠礼自动发奖
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendWealthGodGiftReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), eGamePlayerEventType.WealthGodGifts.getValue());
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        String mailTitleKey = MailManager.CSZLJLBF_ITEM_TITLE;
        String mailContentKey = MailManager.CSZLJLBF_ITEM_CONTENT;
        for (UserActivityConditionData conditionData : allConditionData) {
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if (tempList == null) {
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }
        boolean isAllSend = true;
        int conditionId = 0;
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {  //已领奖
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(BigInteger.ONE) < 0) {   //没买
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if (reward.isNothing()) {
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(mailTitleKey, language), ActivityMgr.getActivityName(activityInfo, language));
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language), "");
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }

    }

    /**
     * 苗寨等换皮活动自动发奖
     *
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendTrystActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), eGamePlayerEventType.TrystValueRise.getValue());
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        String mailTitleKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_TITLE;
        String mailContentKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_CONTENT;
      /*  if(activityInfo.getChildType() != 1){
            mailTitleKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_TITLE + "_" + activityInfo.getChildType();
            mailContentKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_CONTENT + "_" + activityInfo.getChildType();
        }*/
        for (UserActivityConditionData conditionData : allConditionData) {
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if (tempList == null) {
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }
        boolean isAllSend = true;
        int conditionId = 0;
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if (reward.isNothing()) {
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(mailTitleKey, language), ActivityMgr.getActivityName(activityInfo, language));
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language), "");
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 小玉服装活动自动发奖
     *
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendXiaoyuCostumeActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), eGamePlayerEventType.XiaoyuCostumeActivityProgressValue.getValue());
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        String mailTitleKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_TITLE;
        String mailContentKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_CONTENT;
      /*  if(activityInfo.getChildType() != 1){
            mailTitleKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_TITLE + "_" + activityInfo.getChildType();
            mailContentKey = MailManager.TRYST_ACTIVITY_PROGRESS_AUTO_REWARD_CONTENT + "_" + activityInfo.getChildType();
        }*/
        for (UserActivityConditionData conditionData : allConditionData) {
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if (tempList == null) {
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }
        boolean isAllSend = true;
        int conditionId = 0;
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if (reward.isNothing()) {
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(mailTitleKey, language), ActivityMgr.getActivityName(activityInfo, language));
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language), "");
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }


    /**
     * 水浒卡活动结束发奖
     */
    private static void autoSendShuiHuActivityReward(ActivityDetail detail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        // 获取活动数据、配置、条件
        Map<Long, ShuiHuUserData> userDataMap = ShuiHuActivityBussiness.getAutoRewardUserDataMap(activityInfo.getActivityId());
        ShuiHuConfig config = null;
        try {
            config = ShuiHuMgr.loadShuiHuConfigFromDb(activityInfo);
        } catch (Exception e) {
            logger.error("NormalActivityMgr autoSendShuiHuActivityReward error on ShuiHuMgr.loadShuiHuConfigFromDb, activityId={}", activityInfo.getActivityId());
            // 旧活动配置有问题，直接改为已完成
            detail.setAutoSendRewardState(1);
            return;
        }
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), eGamePlayerEventType.ShuiHuAllCombTimes.getValue());
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        for (UserActivityConditionData conditionData : allConditionData) {
            if (!userConditionData.containsKey(conditionData.getUserId())) {
                userConditionData.put(conditionData.getUserId(), new ArrayList<>());
            }
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            tempList.add(conditionData);
        }
        // 一个个发奖
        boolean isAll = true;
        for (ShuiHuUserData userData : userDataMap.values()) {
            long userId = userData.getUserId();
            String userDataBak = JSONObject.toJSONString(userData);
            // 活动数据修改
            Property combReward = ShuiHuMgr.autoSendReward(config, userData);
            int maxCombTimes = ShuiHuMgr.calAllCombTimes(config, userData);
            // 活动条件修改
            int conditionId = 0;
            List<UserActivityConditionData> userActivityConditionDataList = userConditionData.get(userData.getUserId());
            for (UserActivityConditionData conditionData : userActivityConditionDataList) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.error("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", detail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }

                conditionData.setValue(BigInteger.valueOf(maxCombTimes));
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }

                userData.setAutoReward(true);
                if (!ShuiHuActivityBussiness.updateShuiHuUserData(userData)) {
                    logger.error("auto send activity reward save ShuiHuUserData db fail, activityId:{},userId:{},conditionId:{}", detail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    isAll = false;
                    continue;
                }

                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionData(conditionData)) {
                    logger.error("auto send activity reward save UserActivityConditionData db fail, activityId:{},userId:{},conditionId:{}. userDataBak={}", detail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId(), userDataBak);
                    isAll = false;
                    continue;
                }

                Property conditionReward = PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr());
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());

                // 全部奖励
                combReward.addProperty(conditionReward);
            }
            if (combReward.isNothing()) {
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = MultipleLanguageMgr.getContent(MailManager.SHUIHU_ACTIVITY_AUTO_SEND_REWARD_TITLE, language);
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.SHUIHU_ACTIVITY_AUTO_SEND_REWARD_CONTENT, language),
                    ActivityMgr.getActivityName(activityInfo, language));
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(combReward), mailContent, mailTitle);
        }
        if (isAll) {
            detail.setAutoSendRewardState(1);
        }
    }


    /**
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendTreasureActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        ArrayList<Integer> list = new ArrayList<>(1);
        list.add(TreasureActivityMgr.CONDITION_TYPE_PROGRESS);
        autoSendActivityProcessReward(activityDetail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
    }

    /**
     * 小舞回忆录活动结束自动发放图中完成但未领取奖励，以及活动记忆之魂进度领奖
     */
    private static void autoSendXiaowuActivityReward(ActivityDetail detail, ActivityInfo activityInfo) {
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        //获取活动数据
        Map<Long, XiaowuRecallUserData> userDataMap = XiaowuRecallBusiness.getAutoRewardUserDataMap(activityInfo.getActivityId());
        XiaowuConfig config = null;
        try {
            config = XiaowuRecallMgr.loadXiaowuConfigFromDb(activityInfo);
        } catch (Exception e) {
            logger.error("NormalActivityMgr autoSendXiaowuRecallActivityReward error on XiaowuMgr.loadXiaowuConfigFromDb,activityid={}", activityInfo.getActivityId());
            detail.setAutoSendRewardState(1);
            return;
        }
        boolean allSend = true;
        for (XiaowuRecallUserData userData : userDataMap.values()) {

            long userId = userData.getUserId();

            //活动奖励取出
            String combIds = new String();
            for (int combId : XiaowuRecallMgr.checkNoGotRewardComb(config, userData)) {
                if (combIds.isEmpty()) {
                    combIds = combId + "";
                } else {
                    combIds += "," + combId;
                }
            }
            Property combReward = XiaowuRecallMgr.autoSendReward(config, userData);
            if (combReward.isNothing()) {
                continue;
            }
            if (!XiaowuRecallBusiness.updateXiaowuRecallUserData(userData)) {
                logger.error("auto send XiaowuRecallActivity reward saveData fail,activityId:{},userId:{}", detail.getActivityId(), userData.getUserId());
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }

            AutoLogMgr.add(new LogXiaowuRecallReward(config.getActivityId(), userId, 2, userData.getPage(), combIds, PropertyHelper.parsePropertyToString(combReward)));
            String activityName = ActivityMgr.getActivityName(activityInfo, language);
            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE,
                    language), activityName);
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT,
                    language), activityName);
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(combReward), mailContent, mailTitle);
        }
        //发放记忆之魂进度奖励,并且在方法内更新detail自动发放标识
        ArrayList<Integer> list = new ArrayList<>(1);
        list.add(eGamePlayerEventType.XiaowuRecallSoulTask.getValue());
        autoSendActivityProcessReward(detail, activityInfo, list, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
    }

    /**
     * 重归汴梁自动发奖
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendOldPlayerReturnActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        Map<Long, OldPlayerReturnUserData> userDataMap = OldPlayerReturnMgr.getNoSendRewardUserIdMap(activityInfo.getActivityId());
        List<Integer> activityIdList = new ArrayList<>();
        activityIdList.add(activityInfo.getActivityId());
        Map<Integer, Map<Long, Map<Integer, List<UserActivityConditionData>>>> activityAllConditionData = UserActivityBussiness.getActivityAllConditionData(activityIdList);
        Map<Long, Map<Integer, List<UserActivityConditionData>>> allConditionDataMap = activityAllConditionData.get(activityInfo.getActivityId());
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        String mailTitleKey = MailManager.OLD_PLAYER_RETURN_CONDITION_REWARD_TITLE;
        String mailContentKey = MailManager.OLD_PLAYER_RETURN_CONDITION_REWARD_CONTENT;
        for (Long userId : userDataMap.keySet()) {
            Map<Integer, List<UserActivityConditionData>> listMap = allConditionDataMap.get(userId);
            if (listMap == null) {
                continue;
            }
            List<UserActivityConditionData> conditionDataList = new ArrayList<>();
            for (List<UserActivityConditionData> list : listMap.values()) {
                conditionDataList.addAll(list);
            }
            userConditionData.put(userId, conditionDataList);
        }
        boolean isAllSend = true;
        int conditionId;
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            OldPlayerReturnUserData userData = userDataMap.get(userId);
            if (userData.isAlreadyBind() && !userData.isSendBindConditionRewardState()) {
                userData.setSendBindConditionRewardState(true);
            }
            if (userData.isReturn() && !userData.isSendReturnConditionRewardState()) {
                userData.setSendReturnConditionRewardState(true);
            }
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if (reward.isNothing()) {
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(mailTitleKey, language), ActivityMgr.getActivityName(activityInfo, language));
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language), ActivityMgr.getActivityName(activityInfo, language));
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 秋夕雅宴的,游戏未结算的要补发
     */
    private static void autoSendEveFeastGameSettleReward(ActivityInfo activityInfo) {
        List<UserEveFeastData> needAutoUserEveFeastList = new UserEveFeastDaoImpl().getNeedAutoUserEveFeastList(activityInfo.getActivityId());
        if (needAutoUserEveFeastList == null || needAutoUserEveFeastList.isEmpty()) {
            return;
        }
        for (UserEveFeastData userEveFeastData : needAutoUserEveFeastList) {
            String reward = userEveFeastData.getAutoReward();

            userEveFeastData.setAutoReward("");
            new UserEveFeastDaoImpl().update(userEveFeastData);

            long userId =  userEveFeastData.getUserId();
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }

            String mailTitle = MultipleLanguageMgr.getContent("EVEFEAST_MALL_TITLE", language);
            String mailContent = MultipleLanguageMgr.getContent("EVEFEAST_MALL_CONTENT", language);
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), reward, mailContent, mailTitle);
        }
    }

    /**
     * 妙音坊冲榜 玩家未领取的演出奖励要补发
     */
    private static void autoSendMusicRoomRankShowReward(ActivityInfo activityInfo) {
        List<UserMusicRoomRankBeautyData> dataList = new UserMusicRoomRankBeautyDaoImpl().getNeedAutoSendRewardBeautyData(activityInfo.getActivityId());
        Map<Long, Property> userRewardMap = new HashMap<>();
        for (UserMusicRoomRankBeautyData beautyData : dataList) {
            Property showReward = beautyData.getShowReward();

            beautyData.resetJoin();
            new UserMusicRoomRankBeautyDaoImpl().update(beautyData);

            Property totalReward = userRewardMap.getOrDefault(beautyData.getUserId(), new Property());
            totalReward.addProperty(showReward);
            userRewardMap.put(beautyData.getUserId(), totalReward);
        }

        for (Map.Entry<Long, Property> entry : userRewardMap.entrySet()) {
            long userId = entry.getKey();
            if (entry.getValue().isNothing()) {
                continue;
            }
            String reward = PropertyHelper.parsePropertyToString(entry.getValue());
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }

            String activityName = ServerLanguageMgr.getContent(activityInfo.getActivityName(), language);

            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_TITLE, language), activityName);
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CROSS_RANK_REWARD_CONTENT, language), activityName);
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), reward, mailContent, mailTitle);
        }
    }


    /**
     * 自动补发放寻宝活动的进度奖励(非排行)
     *
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendActivityProcessReward(ActivityDetail activityDetail, ActivityInfo activityInfo, List<Integer> conditionTypeList, String mailTitleKey, String mailContentKey) {
        List<UserActivityConditionData> allConditionData = new ArrayList<>();
        if (conditionTypeList != null) {
            for (int conditionType : conditionTypeList) {
                List<UserActivityConditionData> data = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), conditionType);
                allConditionData.addAll(data);

            }
        }

        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();

        for (UserActivityConditionData conditionData : allConditionData) {
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if (tempList == null) {
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }
        boolean isAllSend = true;
        int conditionId = 0;
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.error("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                // 判断达成条件
                if (conditionData.getType() == eGamePlayerEventType.ZhouNianTurntableTimes.getValue()) {
                    if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(1)) < 0) {
                        continue;
                    }
                } else if (conditionData.getType() == eGamePlayerEventType.RechargeVipExpDay.getValue()) {
                    if (!RechargeVipDayCondition.isCompleted(conditionData, activityConditionInfo)) {
                        continue;
                    }
                } else if (conditionData.getType() == eGamePlayerEventType.GashaponIngotRebate.getValue()) { //
                    // 幸运扭蛋元宝返利进度判断位在第一个 300|0|0|0
                    if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(0)) < 0) {
                        continue;
                    }
                } else {
                    if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                        continue;
                    }
                }


                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }

            delReward(activityInfo,reward);

            if (reward.isNothing()) {
                continue;
            }

            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String activityName = ActivityMgr.getActivityName(activityInfo, language);

            String mailTitle = mailTitleKey;
            String mailContent = mailContentKey;
            if (mailTitleKey.equals(MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE)) {
                //{0}活动进度未领取奖励发放
                //亲爱的掌柜，您在 {0}活动中还有未领取的进度奖励，现已补发，敬请查收。
                mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(mailTitleKey, language), activityName);
                mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language),
                        activityName);
            } else if (mailTitleKey.equals(MailManager.FUND_EXPIRE_MAIL_TITLE)) {
                mailTitle = MultipleLanguageMgr.getContent(mailTitleKey, language);
                mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language), activityName);
            } else {
                //其他格式
                mailTitle = MultipleLanguageMgr.getContent(mailTitleKey, language);
                mailContent = MultipleLanguageMgr.getContent(mailContentKey, language);
            }
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 补发活动成就奖励
     */
    private static void autoSendActivityConditionReward(ActivityDetail activityDetail, ActivityInfo activityInfo, List<Integer> conditionTypeList) {
        List<UserActivityConditionData> allConditionData = new ArrayList<>();
        if (conditionTypeList != null) {
            for (int conditionType : conditionTypeList) {
                List<UserActivityConditionData> data = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), conditionType);
                allConditionData.addAll(data);
            }
        }

        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        for (UserActivityConditionData conditionData : allConditionData) {
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if (tempList == null) {
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }

        boolean isAllSend = true;
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.error("auto send activity condition reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                int conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if (reward.isNothing()) {
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            // 发邮件
            String activityName = ActivityMgr.getActivityName(activityInfo, language);
            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CONDITION_REWARD_TITLE, language), activityName);
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.AUTO_SEND_ACTIVITY_CONDITION_REWARD_CONTENT, language), activityName);
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    //对要自动发的奖励特殊处理
    private static void delReward(ActivityInfo activityInfo,Property reward){
        if(activityInfo.getType() == eActivityType.ChineseChess.getValue()){
            //象棋大逃杀不补发象棋皮肤和对战卡回收道具
            Map<Integer, GoodsInfo> goodsMap = GoodsMgr.getGoodsMapByType(eGoodsType.ChineseChessSkin.getValue());
            for(GoodsInfo goodsInfo : goodsMap.values()){
                reward.removeProperty(goodsInfo.getGoodsId());
            }
            reward.removeProperty(ChineseChessMgr.getPlayItemId());
            reward.removeProperty(ChineseChessMgr.getChineseChessReviveItemId());
        }
        if(activityInfo.getType() == eActivityType.GreatTradeActivity.getValue()){
            //成就奖励不发继承点
            reward.removeProperty(eItemId.GREAT_TRADE_JI_CHENG_DIAN.getValue());
        }
        if (activityInfo.getType() == eActivityType.ActivityFund.getValue()) {
            //冰雪基金不补发建筑材料
            reward.removeProperty(eItemId.SnowIceBuildingGoods.getValue());
            reward.removeProperty(eItemId.SnowIceSecondGoods.getValue());
        }
    }

    /**
     * 想起大淘沙活动结束自动发成就奖励
     */
    private static void autoSendChineseChessReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.ChineseChessGoldToken.getValue());
        typeList.add(eGamePlayerEventType.ChineseChessSilverToken.getValue());
        typeList.add(eGamePlayerEventType.ChineseChessBronzeToken.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.CHINESE_CHESS_ACTIVITY_AUTO_REWARD_TITLE, MailManager.CHINESE_CHESS_ACTIVITY_AUTO_REWARD_CONTENT);
    }

    private static void autoSendRankUnionWarReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
    }

    private static void autoSendTwinsReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
//        typeList.add(eGamePlayerEventType.TwinsUserScoreRank.getValue());
//        typeList.add(eGamePlayerEventType.TwinsUnionScoreRank.getValue());
//        typeList.add(eGamePlayerEventType.TwinsPassDamageRank.getValue());
        typeList.add(eGamePlayerEventType.TwinsKangfuComb.getValue());
        typeList.add(eGamePlayerEventType.TwinsKangfuAllLevel.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.TWINS_ACTIVITY_AUTO_REWARD_TITLE, MailManager.TWINS_ACTIVITY_AUTO_REWARD_CONTENT);
    }

    /**
     * 兰若寺活动结束自动发成就奖励
     */
    private static void autoSendLanRuoSiReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.LanRuoSiAttackMonsterNumByType.getValue());
        typeList.add(eGamePlayerEventType.LanRuoSiAttackMonsterTotalDamage.getValue());
        typeList.add(eGamePlayerEventType.LanRuoSiAttackMonsterOnceMaxBlock.getValue());
        typeList.add(eGamePlayerEventType.LanRuoSiAttackMonsterTotalNum.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.LANRUOSI_ACTIVITY_ACHIEVEMENT_REWARD_TITLE, MailManager.LANRUOSI_ACTIVITY_ACHIEVEMENT_REWARD_CONTENT);
    }

    /**
     * 水浒叶子牌活动结束自动发成就奖励
     */
    private static void autoSendShuiHuYeZiCardReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.ShuiHuYeZiCardTotalCardLevel.getValue());
        typeList.add(eGamePlayerEventType.ShuiHuYeZiCardMaxScoreLevel.getValue());
        typeList.add(eGamePlayerEventType.ShuiHuYeZiCardNumberOfGoldCards.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.SHUIHUYEZICARD_ACTIVITY_ACHIEVEMENT_REWARD_TITLE, MailManager.SHUIHUYEZICARD_ACTIVITY_ACHIEVEMENT_REWARD_CONTENT);
    }


    /**
     * 海上争霸活动结束自动发成就奖励
     */
    private static void autoSendSeacraftSouthSeaReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.SeacraftSouthSeaGetMedalNum.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.SEACRAFT_ACHIEVEMENT_TITLE, MailManager.SEACRAFT_ACHIEVEMENT_CONTENT);
    }

    /**
     * 巅峰海上争霸活动结束自动发成就奖励
     */
    private static void autoSendPeakSeacraftReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.PeakSeacraftArea.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }


    /**
     * 夏越活动结束自动发组合奖励
     */
    private static void autoSendXiaYueCombReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.XiaYueCombTimes.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.XIAYUE_ACTIVITY_AUTO_SEND_REWARD_TITLE, MailManager.XIAYUE_ACTIVITY_AUTO_SEND_REWARD_CONTENT);
    }

    /**
     * 玩具屋自动发奖
     */
    private static void autoSendToyHouseAllReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }

        // 自动发订单奖励
        autoSendActivityCombReward(activityDetail, activityInfo);

        // 自动发糖果子成就
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.ToyHouseCandyCount.getValue());
        String title = "";
        String content = "";
        if (activityInfo.getChildType() == 1) {
            title = MailManager.TOY_HOUSE_ACTIVITY_REWARD_TITLE;
            content = MailManager.TOY_HOUSE__ACTIVITY_REWARD_CONTENT;
        } else if (activityInfo.getChildType() == 2) {
            title = "MANUAL_HOUSE_ACTIVITY_REWARD_TITLE";
            content = "MANUAL_HOUSE__ACTIVITY_REWARD_CONTENT";
        }
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                title, content);
    }

    /**
     * 蜀山补发成就
     */
    private static void autoSendShuShanReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.ShuShanFinishEncounter.getValue());
        typeList.add(eGamePlayerEventType.ShuShanBuildTotalLevel.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.SHUSHAN_ACHIEVEMENT_TITLE, MailManager.SHUSHAN_ACHIEVEMENT_CONTENT);
    }

    /**
     * 逐鹿隋唐战功补发
     */
    private static void autoSendSuiTangReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.SuiTangUserZhanGong.getValue());

        autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
    }

    /**
     * 高山鸣琴补发
     */
    private static void autoSendHarpsReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.HarpsPlaySum.getValue());

        autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_TITLE, MailManager.TREASURE_ACTIVITY_PROGRESS_REWORD_CONTENT);
    }

    /**
     * 统兵演武战功补发
     */
    private static void autoSendTongBingReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.TongBingZhanGong.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.TONG_BING_ZHAN_GONG_TITLE, MailManager.TONG_BING_ZHAN_GONG_CONTENT);
    }
    private static void autoSendTonBingReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.TonBingZhanGong.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.TON_BING_ZHAN_GONG_TITLE, MailManager.TON_BING_ZHAN_GONG_CONTENT);
    }

    private static void autoSendChannelTonBingReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.TonBingZhanGong.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList, MailManager.CTON_BING_ZHAN_GONG_TITLE, MailManager.CTON_BING_ZHAN_GONG_CONTENT);
    }

    /**
     * 畅音阁补发
     */
    private static void autoSendOperaMaskReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.OperaMaskBronzeToken.getValue());
        typeList.add(eGamePlayerEventType.OperaMaskSilverToken.getValue());
        typeList.add(eGamePlayerEventType.OperaMaskGoldToken.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    /**
     * 吴刚伐桂补发成就
     */
    private static void autoSendFellingTreesReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.FellingTreesAttackCondition.getValue());
        typeList.add(eGamePlayerEventType.FellingTreesLevelCondition.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }


    /**
     * 玩具屋自动发组合奖励
     */
    private static void autoSendActivityCombReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        Map<Integer, Map<String, ActivityConfig>> configMap = ActivityBussiness.getActivityConfigMap(Collections.singletonList(activityDetail.getActivityId()));
        int candyItemId = configMap.get(activityDetail.getActivityId()).get(eActivityConfigType.TOY_HOUSE_SPECIAL_SCORE_ITEM_ID.getName()).getIntValue();
        logger.info("ToyHouse {} candy item id {}.", activityDetail.getActivityId(), candyItemId);

        // 全部condition
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), eGamePlayerEventType.ToyHouseCombTimes.getValue());
        // 按玩家分类
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        for (UserActivityConditionData conditionData : allConditionData) {
            userConditionData.putIfAbsent(conditionData.getUserId(), new ArrayList<>());
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            tempList.add(conditionData);
        }
        // 按玩家发奖
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                int conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }

            long candyCount = reward.getCountByGoodsId(candyItemId).longValue();
            logger.info("userId {} activityId {} auto send ToyHouse comb reward contains candy count = {}", userId, activityInfo.getActivityId(), candyCount);
            reward.removeProperty(candyItemId);

            // 邮件
            if (!reward.isNothing()) {
                UserInfo userInfo = UserMgr.getUserInfo(userId);
                String language = LanguageType.LANGUAGE_DEFAULT;
                if (null != userInfo) {
                    language = userInfo.getLanguage();
                }

                String mailTitle = "";
                String mailContent = "";
                if (activityInfo.getChildType() == 1) {
                    mailTitle = MultipleLanguageMgr.getContent(MailManager.TOY_HOUSE_ACTIVITY_CONDITION_REWARD_TITLE, language);
                    mailContent = MultipleLanguageMgr.getContent(MailManager.TOY_HOUSE__ACTIVITY_CONDITION_REWARD_CONTENT, language);
                } else if (activityInfo.getChildType() == 2) {
                    mailTitle = MultipleLanguageMgr.getContent("MANUAL_HOUSE_ACTIVITY_CONDITION_REWARD_TITLE", language);
                    mailContent = MultipleLanguageMgr.getContent("MANUAL_HOUSE__ACTIVITY_CONDITION_REWARD_CONTENT", language);
                }
                MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
            }

            // 加糖果子
            if (candyCount > 0) {
                LogMgr.addLogToyHouseCandy(new LogToyHouseCandy(userId, activityInfo.getActivityId(), eLogMoneyType.ToyHouseCombAutoSendReward.getValue(), candyItemId, candyCount, 3, -1L));
                long now = System.currentTimeMillis() / 1000;
                List<UserActivityConditionData> tmpConditionDataList = UserActivityBussiness.getUserActivityConditionDataListByUserIdAndType(activityInfo.getActivityId(), userId, eGamePlayerEventType.ToyHouseCandyCount.getValue());
                for (UserActivityConditionData tmpConditionData : tmpConditionDataList) {
                    if (!tmpConditionData.isGetReward()) {
                        tmpConditionData.setValue(tmpConditionData.getValue().add(BigInteger.valueOf(candyCount)));
                        tmpConditionData.setModifyTime(now);
                        // 更新condition
                        UserActivityBussiness.updateUserActivityConditionData(tmpConditionData);
                    }
                }
            }

        }
    }


    private static void autoSendWinterLoveCombReward(ActivityDetail detail, ActivityInfo activityInfo) {
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        //获取活动数据
        Map<Long, WinterLoveUserData> userDataMap = WinterLoveBusiness.getWinterLoveAutoRewardMap(activityInfo.getActivityId());
        WinterLoveConfig config = null;
        try {
            config = WinterLoveMgr.loadWinterLoveConfigFromDb(activityInfo);
        } catch (Exception e) {
            logger.error("NormalActivityMgr autoSendWinterLoveActivityReward error on WinterLoveMgr.loadWinterLoveConfigFromDb,activityid = {}", activityInfo.getActivityId());
            detail.setAutoSendRewardState(1);
            return;
        }
        for (WinterLoveUserData userData : userDataMap.values()) {
            long userId = userData.getUserId();
            int blessItemId = config.getBlessItemId();
            Property combReward = WinterLoveMgr.autoSendReward(config, userData);
            long blessCount = combReward.getCountByGoodsId(blessItemId).longValue();
            logger.info("userId {} activityId {} auto send WinterLove comb reward contains bless count = {}", userId, activityInfo.getActivityId(), blessCount);
            combReward.removeProperty(blessItemId);
            if (combReward.isNothing() && blessCount <= 0) {
                continue;
            }
            if (!WinterLoveBusiness.updateWinterLoveUserData(userData)) {
                logger.error("auto send WinterLoveActivity reward saveData fail,activityId:{},userId:{}", detail.getActivityId(), userData.getUserId());
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String activityName = ActivityMgr.getActivityName(activityInfo, language);
            String titleKey = config.getMAIL_TITLE_COMBO_REWORD();
            boolean useServerLanguage = true;
            if (StringUtils.isNullOrEmpty(titleKey)) {
                titleKey = MailManager.WINTER_LOVE_AUTO_SEND_COMB_REWARD_TITLE;
                useServerLanguage = false;
            }
            String contentKey = config.getMAIL_CONTENT_COMBO_REWORD();
            if (StringUtils.isNullOrEmpty(contentKey)) {
                contentKey = MailManager.WINTER_LOVE_AUTO_SEND_COMB_REWARD_CONTENT;
            }
            if (useServerLanguage) {
                String mailTitle = StringUtils.format(ServerLanguageMgr.getContent(titleKey,
                        language), activityName);
                String mailContent = StringUtils.format(ServerLanguageMgr.getContent(contentKey,
                        language), activityName);
                MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(combReward), mailContent, mailTitle);
            }else {
                String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(titleKey,
                        language), activityName);
                String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(contentKey,
                        language), activityName);
                MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(combReward), mailContent, mailTitle);
            }
            if (blessCount > 0){
                List<UserActivityConditionData> tmpConditionDataList = UserActivityBussiness.getUserActivityConditionDataListByUserIdAndType(activityInfo.getActivityId(), userId, eGamePlayerEventType.WinterLoveBlessCount.getValue());
                for (UserActivityConditionData tmpConditionData : tmpConditionDataList) {
                    if (!tmpConditionData.isGetReward()) {
                        tmpConditionData.setValue(tmpConditionData.getValue().add(BigInteger.valueOf(blessCount)));
                        tmpConditionData.setModifyTime(now);
                        // 更新condition
                        UserActivityBussiness.updateUserActivityConditionData(tmpConditionData);
                    }
                }
            }

        }

        String progressRewordTitle = config.getMAIL_TITLE_PROGRESS_REWORD();
        boolean useServerLanguage = true;
        if (StringUtils.isNullOrEmpty(progressRewordTitle)) {
            progressRewordTitle = MailManager.WINTER_LOVE_AUTO_SEND_BLESS_REWARD_TITLE;
            useServerLanguage = false;
        }

        String progressRewordContent = config.getMAIL_CONTENT_PROGRESS_REWORD();

        if (StringUtils.isNullOrEmpty(progressRewordContent)) {
            progressRewordContent = MailManager.WINTER_LOVE_AUTO_SEND_BLESS_REWARD_CONTENT;
        }

        //顺便补发美女祝福奖励
        if (useServerLanguage) {
            autoSendActivityRewardWithServerLanguage(detail, activityInfo, eGamePlayerEventType.WinterLoveBlessCount.getValue(),progressRewordTitle, progressRewordContent);
        }else {
            autoSendActivityReward(detail, activityInfo, eGamePlayerEventType.WinterLoveBlessCount.getValue(), progressRewordTitle, progressRewordContent);
        }
    }

    //秦始皇陵补发  1.秦俑在世黏土使用商会进度奖励 2.地宫遗物博物点奖励
    private static void autoSendTombActivityReward(ActivityDetail detail, ActivityInfo activityInfo) {
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        try {
        } catch (Exception e) {
            return;
        }
        List<Integer> conditionTypeList = new ArrayList<>();
        conditionTypeList.add(eGamePlayerEventType.TombRelicNum.getValue());        //个人遗物进度
        conditionTypeList.add(eGamePlayerEventType.TombUnionNianTuNum.getValue());  //商会黏土修复进度
        boolean isAllSend = true;
        for (int conditionType : conditionTypeList) {
            String mailTitleKey = "";
            String mailContentKey = "";
            if (conditionType == eGamePlayerEventType.TombRelicNum.getValue()) {
                mailTitleKey = MailManager.TOMB_RELIC_RANK_REWARD_TITLE;
                mailContentKey = MailManager.TOMB_RELIC_RANK_REWARD_CONTENT;
            } else {
                mailTitleKey = MailManager.TOMB_CLAY_RANK_REWARD_TITLE;
                mailContentKey = MailManager.TOMB_CLAY_RANK_REWARD_CONTENT;
            }

            List<UserActivityConditionData> data = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), conditionType);
            Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
            for (UserActivityConditionData conditionData : data) {
                List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
                if (tempList == null) {
                    tempList = new ArrayList<>();
                    userConditionData.put(conditionData.getUserId(), tempList);
                }
                tempList.add(conditionData);
            }

            int conditionId = 0;
            for (Long userId : userConditionData.keySet()) {
                Property reward = new Property();
                for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                    if (conditionData.isGetReward()) {
                        continue;
                    }
                    ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                    if (activityConditionInfo == null) {
                        logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", detail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                        continue;
                    }
                    conditionId = activityConditionInfo.getConditionId();
                    if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                        continue;
                    }
                    conditionData.setGetReward(true);
                    if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                        isAllSend = false;
                        logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", detail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                        continue;
                    }
                    reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                    LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                            conditionId, 0, true, activityConditionInfo.getRewardStr());
                }
                if (reward.isNothing()) {
                    continue;
                }
                UserInfo userInfo = UserMgr.getUserInfo(userId);
                String language = LanguageType.LANGUAGE_DEFAULT;
                if (null != userInfo) {
                    language = userInfo.getLanguage();
                }
                String mailTitle = MultipleLanguageMgr.getContent(mailTitleKey, language);
                String mailContent = MultipleLanguageMgr.getContent(mailContentKey, language);
                MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
            }
        }
        if (isAllSend){
            detail.setAutoSendRewardState(1);
        }
    }


    /**
     * 蛐蛐活动补发榜单奖励
     */
    private static void autoSendCricketActivityConditionReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        // 废弃
//        typeList.add(eGamePlayerEventType.CricketRankRank.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }


    /**
     * 汴梁世界杯补发
     */
    private static void autoSendWorldCupReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.WorldCupSkillLevel.getValue());
        autoSendActivityConditionReward(activityDetail, activityInfo, typeList);
    }

    /**
     * 自动补发活动的进度奖励(非排行+活动结束后)
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo, int conditionType, String mailTitleKey, String  mailContentKey) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), conditionType);
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        for(UserActivityConditionData conditionData : allConditionData){
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if(tempList == null){
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }
        boolean isAllSend = true;
        int conditionId = 0;
        for(Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if(reward.isNothing()){
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = MultipleLanguageMgr.getContent(mailTitleKey, language);
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language),
                    ActivityMgr.getActivityName(activityInfo, language));
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if(isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 自动补发活动的进度奖励(非排行+活动结束后)
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendActivityRewardWithServerLanguage(ActivityDetail activityDetail, ActivityInfo activityInfo, int conditionType, String mailTitleKey, String  mailContentKey) {
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), conditionType);
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        for(UserActivityConditionData conditionData : allConditionData){
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if(tempList == null){
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }
        boolean isAllSend = true;
        int conditionId = 0;
        for(Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if(reward.isNothing()){
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = StringUtils.format(ServerLanguageMgr.getContent(mailTitleKey, language),ActivityMgr.getActivityName(activityInfo, language)) ;
            String mailContent = StringUtils.format(ServerLanguageMgr.getContent(mailContentKey, language),
                    ActivityMgr.getActivityName(activityInfo, language));
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if(isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }


    /**
     * 自动补发放节日活动的进度奖励(非排行)
     * @param activityDetail
     * @param activityInfo
     */
    private static void autoSendHolidayActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        List<UserActivityConditionData> allConditionData = UserActivityBussiness.getUserActivityConditionDataListByType(activityInfo.getActivityId(), HolidayActivityMgr.CONDITION_TYPE_PROGRESS);
        Map<Long, List<UserActivityConditionData>> userConditionData = new HashMap<>();
        String mailTitleKey = MailManager.HOLIDAY_ACTIVITY_PROGRESS_REWORD_TITLE;
        String mailContentKey = MailManager.HOLIDAY_ACTIVITY_PROGRESS_REWORD_CONTENT;
        if (activityInfo.getChildType() != 1) {
            mailTitleKey = MailManager.HOLIDAY_ACTIVITY_PROGRESS_REWORD_TITLE + "_" + activityInfo.getChildType();
            mailContentKey = MailManager.HOLIDAY_ACTIVITY_PROGRESS_REWORD_CONTENT + "_" + activityInfo.getChildType();
        }
        for (UserActivityConditionData conditionData : allConditionData) {
            List<UserActivityConditionData> tempList = userConditionData.get(conditionData.getUserId());
            if (tempList == null) {
                tempList = new ArrayList<>();
                userConditionData.put(conditionData.getUserId(), tempList);
            }
            tempList.add(conditionData);
        }
        boolean isAllSend = true;
        int conditionId = 0;
        for (Long userId : userConditionData.keySet()) {
            Property reward = new Property();
            for (UserActivityConditionData conditionData : userConditionData.get(userId)) {
                if (conditionData.isGetReward()) {
                    continue;
                }
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfo(activityInfo.getActivityId(), conditionData.getConditionId());
                if (activityConditionInfo == null) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                conditionId = activityConditionInfo.getConditionId();
                if (conditionData.getValue().compareTo(activityConditionInfo.getParamList().get(3)) < 0) {
                    continue;
                }
                conditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(conditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},conditionId:{}", activityDetail.getActivityId(), conditionData.getUserId(), conditionData.getConditionId());
                    continue;
                }
                reward.addProperty(PropertyHelper.parseStringToProperty(activityConditionInfo.getRewardStr()));
                LogMgr.addLogActivityReward(userId, activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                        conditionId, 0, true, activityConditionInfo.getRewardStr());
            }
            if (reward.isNothing()) {
                continue;
            }
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            String mailTitle = MultipleLanguageMgr.getContent(mailTitleKey, language);
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(mailContentKey, language),
                    ActivityMgr.getActivityName(activityInfo, language));
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), mailContent, mailTitle);
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 自动发放冲榜活动奖励
     */
    private static void autoSendActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        int rankNum = ActivityHelper.getMaxRank(getActivityConditionInfoList(activityDetail.getActivityId()));
        List<UserActivityConditionData> userActivityConditionDataList = UserActivityBussiness.getUserActivityConditionDataList(activityDetail.getActivityId(), rankNum);
        RankListModel rankListModel = RankMgr.getRankListModelByType(eBigRankType.Normal.getValue(), activityDetail.getActivityId());
        if (null == rankListModel) {
            rankListModel = new RankListModel(eBigRankType.Normal.getValue(), activityDetail.getActivityId());
            if (rankNum <= 0) {
                rankNum = GameConfig.RANK_DEFAULT_MAX_COUNT;
            }
            rankListModel.setRankNum(rankNum);
            rankListModel.setRankList(RankMgr.parseUserRankList(userActivityConditionDataList, rankNum));
        }
        String activityName = "Activity_Ranking_List_Name-" + activityInfo.getChildType();
        boolean isAllSend = true;
        for (UserActivityConditionData userActivityConditionData : userActivityConditionDataList) {
            if (userActivityConditionData.isGetReward()) {
                continue;
            }
            int myRank;
            //冲榜活动，获取冲榜排名
            myRank = rankListModel.getMyRank(userActivityConditionData.getUserId());
            if (myRank > 0) {//参与奖不发放
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfoByRank(activityDetail.getActivityId(), myRank);
                if (null == activityConditionInfo) {
                    logger.info("auto send activity reward conditionInfo is null, activityId:{},userId:{},rank:{}",
                            activityDetail.getActivityId(), userActivityConditionData.getUserId(), myRank);
                    continue;
                }
                userActivityConditionData.setGetReward(true);
                if (!UserActivityBussiness.updateUserActivityConditionDataState(userActivityConditionData)) {
                    isAllSend = false;
                    logger.error("auto send activity reward save db fail, activityId:{},userId:{},rank:{}",
                            activityDetail.getActivityId(), userActivityConditionData.getUserId(), myRank);
                    continue;
                }
                sendMailReward(activityInfo, activityName, myRank, activityConditionInfo, userActivityConditionData, false, false, null);
                if (myRank < 4) {//前三
                    GamePlayer player = GamePlayerMgr.getOnlinePlayer(userActivityConditionData.getUserId());
                    if (null != player) {
                        UserHistoryAttribute userHistoryAttribute = player.getModule(PlayerModule.class).getUserHistoryAttribute();
                        userHistoryAttribute.addRankActivityTopThreeTotalTimes(activityInfo.getChildType());
                        player.notifyListener(eGamePlayerEventType.RankActivityTopThreeTotalTimes.getValue(), userHistoryAttribute);
                    }else {
                        UserHistoryAttribute attribute = UserHistoryAttributeBussiness.getUserHistoryAttribute(userActivityConditionData.getUserId());
                        if(attribute != null){
                            attribute.addRankActivityTopThreeTotalTimes(activityInfo.getChildType());
                            UserHistoryAttributeBussiness.updateUserHistoryAttribute(attribute);
                        }
                    }
                }
            }
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 自动发放商会冲榜活动奖励
     */
    private static void autoSendUnionActivityReward(ActivityDetail activityDetail, ActivityInfo activityInfo) {
        int rankNum = ActivityHelper.getMaxRank(getActivityConditionInfoList(activityDetail.getActivityId()));
        Map<Long, UserActivityConditionData> userActivityConditionDataMap = UserActivityBussiness.getUnionActivityUserConditionDataMap(activityDetail.getActivityId());
        Map<String, UnionActivityConditionData> unionActivityConditionDataMap = UserActivityBussiness.getUnionActivityConditionDataMap(activityDetail.getActivityId());
        UnionActivityMgr.checkUnionActivityConditionData(userActivityConditionDataMap, unionActivityConditionDataMap);
        UnionActivityRankListModel rankListModel = UnionActivityMgr.getUnionActivityRankListModel(activityDetail.getActivityId());
        if (null == rankListModel) {
            rankListModel = new UnionActivityRankListModel(activityDetail.getActivityId());
            if (rankNum <= 0) {
                rankNum = 100;
            }
            rankListModel.setRankNum(rankNum);
            rankListModel.initRankList(unionActivityConditionDataMap);
        }
        String activityName = "Union_Activity_Ranking_List_Name-" + activityInfo.getChildType();
        boolean isAllSend = true;
        for (UnionActivityConditionData unionActivityConditionData : unionActivityConditionDataMap.values()) {
            int myRank;
            //冲榜活动，获取冲榜排名
            myRank = rankListModel.getMyRank(unionActivityConditionData.getUnionUid());
            if (myRank > 0) {//参与奖不发放
                ActivityConditionInfo activityConditionInfo = NormalActivityMgr.getActivityConditionInfoByRank(activityDetail.getActivityId(), myRank);
                if (null == activityConditionInfo) {
                    logger.info("auto send union activity reward condition is null, activityId:{},unionUid:{},rank:{}", activityDetail.getActivityId(),
                            unionActivityConditionData.getUnionUid(), myRank);
                    isAllSend = false;
                    continue;
                }
                for (long userId : unionActivityConditionData.getMemberUserIdList()) {
                    UserActivityConditionData userActivityConditionData = userActivityConditionDataMap.get(userId);
                    if (null != userActivityConditionData) {
                        if (userActivityConditionData.isGetReward()) {
                            continue;
                        }
                        userActivityConditionData.setGetReward(true);
                        if (!UserActivityBussiness.updateUserActivityConditionDataState(userActivityConditionData)) {
                            isAllSend = false;
                            logger.error("auto send union activity reward save db fail, activityId:{},userId:{},unionUid:{},rank:{}",
                                    activityDetail.getActivityId(), userActivityConditionData.getUserId(), unionActivityConditionData.getUnionUid(), myRank);
                            continue;
                        }
                        sendMailReward(activityInfo, activityName, myRank, activityConditionInfo, userActivityConditionData, true,
                                unionActivityConditionData.getUnionBaseInfo().getMasterUserId() == userActivityConditionData.getUserId(), unionActivityConditionData);
                    }
                }
            }
        }
        if (isAllSend) {//更新自动发放标识
            activityDetail.setAutoSendRewardState(1);
        }
    }

    /**
     * 牧场点兵活动结束自动发成就奖励
     */
    private static void autoSendPastureReward(ActivityDetail activityDetail, ActivityInfo activityInfo){
        // 稍等一会儿，确保用户那边数据都入库了
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndTime() + 60) {
            return;
        }
        List<Integer> typeList = new ArrayList<>();
        typeList.add(eGamePlayerEventType.PastureGoldToken.getValue());
        typeList.add(eGamePlayerEventType.PastureSilverToken.getValue());
        typeList.add(eGamePlayerEventType.PastureBronzeToken.getValue());
        autoSendActivityProcessReward(activityDetail, activityInfo, typeList,
                MailManager.PASTURE_ACTIVITY_AUTO_REWARD_TITLE, MailManager.PASTURE_ACTIVITY_AUTO_REWARD_CONTENT);
    }

    private static void autoSendQixiGiftReward(ActivityDetail detail, ActivityInfo activityInfo) {
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        //获取活动数据
        Map<Long, List<UserQixiGiftData>> needSendMailGift = new UserQixiGiftDaoImpl().getNeedSendMailGift(activityInfo.getActivityId());

        for (Map.Entry<Long, List<UserQixiGiftData>> entry : needSendMailGift.entrySet()) {
            long userId = entry.getKey();
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            Property giftReward = new Property();
            List<UserQixiGiftData> userQixiGiftDataList = entry.getValue();
            for (UserQixiGiftData userQixiGiftData : userQixiGiftDataList) {
                userQixiGiftData.setStatus(1);
                if (new UserQixiGiftDaoImpl().update(userQixiGiftData)){
                    //发放奖励
                    int flowerId = userQixiGiftData.getFlowerId();
                    GoodsInfo goodsInfo = GoodsMgr.getGoodsById(flowerId);
                    if (goodsInfo == null) {
                        logger.info("autoSendQixiGiftReward goodsInfo is null, userId:{}, flowerId:{}", userId, flowerId);
                        continue;
                    }

                    giftReward.addProperty(QixiMgr.getGiftReward(goodsInfo, userQixiGiftData.getFlowerCount()));
                }
            }
            if (giftReward.isNothing()) {
                logger.error("autoSendQixiGiftReward giftReward is null, userId:{}", userId);
                continue;
            }

            String mailTitle = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.ACTIVITY_GOODS_AUTO_CONSUME_TITLE,
                    language), activityInfo.getActivityName());
            String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.QIXI_MAIL_CONTENT_1, language), activityInfo.getActivityName());
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(giftReward), mailContent, mailTitle);
        }
    }

    private static void autoSendGuaGiftReward(ActivityDetail detail, ActivityInfo activityInfo) {
        long now = System.currentTimeMillis() / 1000;
        if (now < activityInfo.getEndShowTime() + 60) {
            return;
        }
        //获取活动数据
        Map<Long, List<UserGuaGiftData>> needSendMailGift = new UserGuaGiftDaoImpl().getNeedSendMailGift(activityInfo.getActivityId());

        for (Map.Entry<Long, List<UserGuaGiftData>> entry : needSendMailGift.entrySet()) {
            long userId = entry.getKey();
            UserInfo userInfo = UserMgr.getUserInfo(userId);
            String language = LanguageType.LANGUAGE_DEFAULT;
            if (null != userInfo) {
                language = userInfo.getLanguage();
            }
            Property giftReward = new Property();
            List<UserGuaGiftData> userGiftDataList = entry.getValue();
            for (UserGuaGiftData userGiftData : userGiftDataList) {
                userGiftData.setStatus(1);
                if (new UserGuaGiftDaoImpl().update(userGiftData)){
                    //发放奖励
                    int flowerId = userGiftData.getGoodsId();
                    GoodsInfo goodsInfo = GoodsMgr.getGoodsById(flowerId);
                    if (goodsInfo == null) {
                        logger.info("autoSendGiftReward goodsInfo is null, userId:{}, flowerId:{}", userId, flowerId);
                        continue;
                    }

                    giftReward.addProperty(GuaGiftsMgr.getGiftReward(goodsInfo, userGiftData.getGoodsCount()));
                }
            }
            if (giftReward.isNothing()) {//孤寡是有没礼物的送礼,所以不打日志
//                logger.error("autoSendGiftReward giftReward is null, userId:{}", userId);
                continue;
            }

            String mailTitle = MultipleLanguageMgr.getContent(MailManager.GUAGIFTS_MAIL_TITLE, language);
            String mailContent = MultipleLanguageMgr.getContent(MailManager.GUAGIFTS_MAIL_CONTENT_1, language);
            MailManager.sendMail(userId, eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(giftReward), mailContent, mailTitle);
        }
    }


    private static void sendMailReward(ActivityInfo activityInfo, String activityName, int myRank, ActivityConditionInfo activityConditionInfo,
                                       UserActivityConditionData conditionData, boolean isUnionRank, boolean isMaster, UnionActivityConditionData unionActivityConditionData) {
        UserInfo userInfo = UserMgr.getUserInfo(conditionData.getUserId());
        String language = LanguageType.LANGUAGE_DEFAULT;
        if (null != userInfo) {
            language = userInfo.getLanguage();
        }
        String mailTitle = MultipleLanguageMgr.getContent(MailManager.RANK_ACTIVITY_FINISH_TITLE, language);
        String mailContent = StringUtils.format(MultipleLanguageMgr.getContent(MailManager.RANK_ACTIVITY_FINISH_CONTENT, language),
                MultipleLanguageMgr.getContent(activityName, language), myRank);
        String reward;
        if (isUnionRank && isMaster) {//会长奖励
            reward = activityConditionInfo.getMasterRewardStr();
        } else if (isUnionRank) {
            reward = UnionActivityMgr.getUnionMemberPositionDataReward(unionActivityConditionData, activityConditionInfo, conditionData.getUserId());
        } else {
            reward = activityConditionInfo.getRewardStr();
        }

        //称号奖励，直接生效
        // reward = ActivityMgr.dealWithMailDecorationReward(activityInfo.getType(), conditionData.getUserId(), reward, eLogMoneyType.Mail, eLogMoneyType.MailOpen);

        MailManager.sendMail(conditionData.getUserId(), eMailType.SYSTEM.getValue(), reward, mailContent, mailTitle);
        LogMgr.addLogActivityReward(conditionData.getUserId(), activityInfo.getActivityId(), activityInfo.getType(), activityInfo.getChildType(),
                activityConditionInfo.getConditionId(), myRank, true, reward);
    }

    private static void playerReloadActivity() {
        List<GamePlayer> playerList = GamePlayerMgr.getCopyPlayerList();
        playerList.forEach(action -> {
            action.getModule(ActivityModule.class).checkNewActivityData();
            action.getModule(ActivityModule.class).syncActivity();
            action.getModule(ActivityModule.class).syncSpecialActivityData();
            //补充值吧
            action.getModule(ActivityModule.class).initRechargeConditionData();
            //商会自动的要看看有没有冲榜活动哦
            action.getModule(BanquetModule.class).syncAutoInfo();

            // 跨地区活动服务器名称下发
            // action.getModule(ChannelActivityModule.class).syncCrossChannelServerName(); // 2022年11月17日 去掉先不发
        });
    }

    public static Map<Integer, ActivityInfo> getShowTimeActivityInfoMap() {
        return showTimeActivityInfoMap;
    }

    /**
     * 获取苗寨幽会活动
     */
    public static List<ActivityInfo> getTrystActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (activityInfo.getEndTime() > nowTime && activityInfo.getBeginTime() < nowTime &&
                    (activityInfo.getType() == eActivityType.TrystActivity.getValue())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    public static List<ActivityInfo> getXiaoyuCostumeActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (activityInfo.getEndTime() > nowTime && activityInfo.getBeginTime() < nowTime &&
                    (activityInfo.getType() == eActivityType.XiaoyuCostumeActivity.getValue())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放的活动
     * @param activityType  活动大类型
     * @return
     */
    public static List<ActivityInfo> getOpenActivityInfoList(int activityType) {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && activityInfo.getType() == activityType) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放的活动
     * @param activityTypeSet  活动大类型集合
     * @return
     */
    public static List<ActivityInfo> getOpenActivityInfoListByTypeSet(Set<Integer> activityTypeSet) {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && activityTypeSet.contains(activityInfo.getType())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放的活动
     * @param activityType  活动大类型
     * @return
     */
    public static List<ActivityInfo> getOpenActivityInfoList(int activityType,int childType) {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && activityInfo.getType() == activityType && activityInfo.getChildType() == childType) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取已开放活动的活动小类型的活动列表
     *
     * @param sourceType 活动类型
     * @param childTypes 活动小类型编号列表
     * @return res
     */
    public static List<ActivityInfo> getInfosByChildTypes(int sourceType, List<Integer> childTypes) {
        List<ActivityInfo> res = new ArrayList<>();

        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            int targetType = activityInfo.getType();
            int targetChildType = activityInfo.getChildType();
            if (ActivityMgr.activityInShowTime(activityInfo) && targetType == sourceType && childTypes.contains(targetChildType)) {
                res.add(activityInfo);
            }
        }

        return res;
    }

    /**
     * 获取开放的活动Id
     * @param activityType  活动大类型
     * @return
     */
    public static List<Integer> getOpenActivityIdList(int activityType) {
        List<Integer> activityIdList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && activityInfo.getType() == activityType) {
                activityIdList.add(activityInfo.getActivityId());
            }
        }
        return activityIdList;
    }

    /**
     * 获取医馆冲榜活动
     * @return
     */
    public static List<Integer> getOpenClinicRankActivityIdList() {
        List<Integer> activityIdList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) &&
                    ((activityInfo.getType() == eActivityType.RankActivity.getValue() && activityInfo.getChildType() == eRankActivityType.ClinicScoreRiseRank.getValue())
                            || (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == eCrossRankActivityType.CrossClinicScoreRiseRank.getValue()))) {
                activityIdList.add(activityInfo.getActivityId());
            }
        }
        return activityIdList;
    }

    /**
     * 获取庄园冲榜活动
     * @return
     */
    public static List<Integer> getOpenManorRankActivityIdList() {
        List<Integer> activityIdList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) &&
                    ((activityInfo.getType() == eActivityType.RankActivity.getValue() && activityInfo.getChildType() == eRankActivityType.ManorOutPutCountRank.getValue())
                            || (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == eCrossRankActivityType.CrossManorOutPutCountRank.getValue()))) {
                activityIdList.add(activityInfo.getActivityId());
            }
        }
        return activityIdList;
    }

    /**
     * 获取酒肆冲榜活动
     * @return
     */
    public static List<Integer> getOpenWineShopRankActivityIdList() {
        List<Integer> activityIdList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) &&
                    ((activityInfo.getType() == eActivityType.RankActivity.getValue() &&
                            (activityInfo.getChildType() == eRankActivityType.WineShopPleasureRiseRank.getValue() || activityInfo.getChildType() == eRankActivityType.BeautyEscortAddExpRank.getValue()))
                            || (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() &&
                            (activityInfo.getChildType() == eCrossRankActivityType.CrossWineShopPleasureRiseRank.getValue() || activityInfo.getChildType() == eCrossRankActivityType.CrossBeautyEscortAddExpRank.getValue())))) {
                activityIdList.add(activityInfo.getActivityId());
            }
        }
        return activityIdList;
    }

    /**
     * 获取药铺冲榜活动
     * @return
     */
    public static List<Integer> getOpenDrugStoreRankActivityIdList(){
        List<Integer> activityIdList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) &&
                    ((activityInfo.getType() == eActivityType.RankActivity.getValue() && activityInfo.getChildType() == eRankActivityType.DrugStoreTongBiRiseRank.getValue())
                    || (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == eCrossRankActivityType.CrossDrugStoreTongBiRiseRank.getValue()))) {
                activityIdList.add(activityInfo.getActivityId());
            }
        }
        return activityIdList;
    }

    public static List<ActivityInfo> getOpenMonopolyMarketActivityList() {
        List<ActivityInfo> activityInfos = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (isMonopolyMarketRankActivity(activityInfo)) {
                activityInfos.add(activityInfo);
            }
        }
        return activityInfos;
    }

    public static boolean isMonopolyMarketRankActivity(ActivityInfo activityInfo) {
        return activityInfo.getType() == eActivityType.CrossRankActivity.getValue()
                && activityInfo.getChildType() == eCrossRankActivityType.CrossMonopolyMarketResGrabRank.getValue();
    }

    /**
     * 获取特惠礼包活动
     */
    public static List<ActivityInfo> getDiscountActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (activityInfo.getEndTime() > nowTime && activityInfo.getBeginTime() < nowTime &&
                    (activityInfo.getType() == eActivityType.RechargeActivity.getValue())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取冲榜战令活动
     */
    public static List<ActivityInfo> getZhanLingActivityInfoList() {
        List<ActivityInfo> activityInfos = new ArrayList<>();
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : allActivityInfoMap.values()) {
            if (activityInfo.getEndTime() > nowTime && activityInfo.getBeginTime() < nowTime &&
                    (activityInfo.getType() == eActivityType.WelfareActivity.getValue())
                    && (activityInfo.getChildType() == eWelfareActivityType.ZhanLingMeiLi.getValue()
                    || activityInfo.getChildType() == eWelfareActivityType.ZhanLingMenKe.getValue()
                    || activityInfo.getChildType() == eWelfareActivityType.ZhanLingZhuanSu.getValue()
                    || activityInfo.getChildType() == eWelfareActivityType.ZhanLingQinMi.getValue()
                    || activityInfo.getChildType() == eWelfareActivityType.ZhanLingYuanBao.getValue())) {
                activityInfos.add(activityInfo);
            }
        }
        return activityInfos;
    }

    /**
     * 获取开放的个人冲榜活动列表（包括本服、跨服）
     */
    public static List<ActivityInfo> getRankActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (activityInfo.getEndShowTime() > nowTime && (
                    activityInfo.getType() == eActivityType.RankActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CrossRankActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CrossHuaShiGangActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CrossDunHuangShiKuActivity.getValue())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放的跨服冲榜列表
     */
    public static List<ActivityInfo> getCrossRankActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && (activityInfo.getType() == eActivityType.CrossRankActivity.getValue()
                    || activityInfo.getType() == eActivityType.CrossUnionActivity.getValue())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放的神秘商人活动列表
     */
    public static List<ActivityInfo> getMysteriousMerchantActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && activityInfo.getType() == eActivityType.MysteriousMerchantActivity.getValue()) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放活动列表
     */
    public static List<ActivityInfo> getShowTimeActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo)) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放的门客组合活动列表
     */
    public static List<ActivityInfo> getPatronsCombActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && activityInfo.getType() == eActivityType.PatronsCombActivity.getValue()) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开放的珍兽组合活动列表
     */
    public static List<ActivityInfo> getVehicleCombActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) && activityInfo.getType() == eActivityType.VehicleCombActivity.getValue()) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    public static List<ActivityInfo> getRechargeActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) &&
                    ((activityInfo.getType() == eActivityType.RechargeActivity.getValue() &&
                    (activityInfo.getChildType() == 4 || activityInfo.getChildType() == 10 || activityInfo.getChildType() == 11|| activityInfo.getChildType() == 13))
                            || activityInfo.getType() == eActivityType.NewRechargeActivity.getValue()
                    )
            ) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    public static ActivityInfo getActivityInfo(int activityId) {
        return showTimeActivityInfoMap.get(activityId);
    }

    public static boolean isCrossActivity(int activityId) {
        ActivityInfo activityInfo = getActivityInfo(activityId);
        if (null != activityInfo) {
            return activityInfo.getType() == eActivityType.CrossRankActivity.getValue();
        }
        return false;
    }

    //跨服宴会冲榜是否在进行，在进行才能开跨服私人宴会
    public static ActivityInfo getRunningCrossBanquetRankActivity() {
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : NormalActivityMgr.getRankActivityInfoList()) {
            if (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == 5) {
                if (nowTime > activityInfo.getBeginTime() && nowTime < activityInfo.getEndTime()) {
                    return activityInfo;
                }
            }
        }
        return null;
    }
    public static ActivityInfo getShowingCrossBanquetRankActivity() {
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : NormalActivityMgr.getRankActivityInfoList()) {
            if (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == 5) {
                if (nowTime > activityInfo.getBeginShowTime() && nowTime < activityInfo.getEndShowTime()) {
                    return activityInfo;
                }
            }
        }
        return null;
    }

    //跨服宴会又在期间
    public static ActivityInfo getExistCrossBanquetRankActivity() {
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : NormalActivityMgr.getRankActivityInfoList()) {
            if (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == 5) {
                if (nowTime > activityInfo.getBeginShowTime() && nowTime < activityInfo.getEndShowTime()) {
                    return activityInfo;
                }
            }
        }
        return null;
    }

    /**
     * 是否跨服商会争霸
     */
    public static boolean isCrossUnionActivity(int activityId) {
        ActivityInfo activityInfo = getActivityInfo(activityId);
        if (null != activityInfo) {
            return activityInfo.getType() == eActivityType.CrossUnionActivity.getValue();
        }
        return false;
    }

    /**
     * 商战积分冲榜活动列表（包括商会商战冲榜）
     */
    public static List<ActivityInfo> getTradeWarScoreRiseRankActivityList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInTime(activityInfo) &&
                    (activityInfo.getType() == eActivityType.RankActivity.getValue() && activityInfo.getChildType() == eRankActivityType.TradeWarScoreRiseRank.getValue()) ||
                    (activityInfo.getType() == eActivityType.UnionRankActivity.getValue() && activityInfo.getChildType() == eUnionRankActivityType.unionTradeWarScoreRiseRank.getValue())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 子嗣赚速冲榜活动列表
     * 包括本服及跨服活动两类
     */
    public static List<ActivityInfo> getChildEarnSpeedRiseRankActivityList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInTime(activityInfo) &&
                    ((activityInfo.getType() == eActivityType.RankActivity.getValue() && activityInfo.getChildType() == eRankActivityType.ChildEarnSpeedRank.getValue())
                            || (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == eCrossRankActivityType.CrossChildEarnSpeedRiseRank.getValue()))) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 商会冲榜活动
     */
    public static List<ActivityInfo> getUnionRiseRankActivityList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInTime(activityInfo) && (activityInfo.getType() == eActivityType.UnionRankActivity.getValue()
                    || activityInfo.getType() == eActivityType.CrossUnionActivity.getValue())) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取全部活动商城数据
     */
    public static Map<Integer, Map<Integer, MallInfo>> getAllActivityMallInfoMap() {
        return allActivityMallInfoMap;
    }

    /**
     * 获取活动商城数据
     */
    public static Map<Integer, MallInfo> getActivityMallInfoMap(int activityId) {
        return allActivityMallInfoMap.get(activityId);
    }

    /**
     * 获取全部活动配置数据
     */
    public static Map<Integer, Map<String, ActivityConfig>> getAllActivityConfigMap() {
        return activityConfigMap;
    }

    /**
     * 获取活动配置数据
     */
    public static Map<String, ActivityConfig> getActivityConfigMap(int activityId) {
        return activityConfigMap.get(activityId);
    }

    /**
     * 获取对应类型的礼包数据
     * @param activityId
     * @param type 礼包类型
     * @return
     */
    public static Map<Integer, MallInfo> getMallInfoTypeMap(int activityId,int type) {
        Map<Integer, MallInfo> mallInfoMap = allActivityMallInfoMap.get(activityId);
        if (mallInfoMap == null) {
            new HashMap<>();
        }

        Map<Integer, MallInfo> tempMap = new HashMap<>();
        for (MallInfo mallInfo : mallInfoMap.values()) {
            if (mallInfo.getShopType() == type) {
                tempMap.put(mallInfo.getMallId(), mallInfo);
            }
        }
        return tempMap;
    }

    /**
     * 跨服争霸，获取商品信息
     */
    public static MallInfo getActivityMallInfo(int activityId, int mallId) {
        Map<Integer, MallInfo> mallInfoMap = getActivityMallInfoMap(activityId);
        if (null != mallInfoMap) {
            return mallInfoMap.get(mallId);
        }
        return null;
    }

    /**
     * 现金礼包通过档位编号获取商品信息（知道活动编号）
     */
    public static MallInfo getRMBActivityMallInfoByGrade(int activityId, int grade) {
        Map<Integer, MallInfo> mallInfoMap = getActivityMallInfoMap(activityId);
        if (null != mallInfoMap) {
            for (MallInfo mallInfo : mallInfoMap.values()) {
                String gradeStr = String.valueOf(grade);
                if (gradeStr.equals(mallInfo.getExtendParam())) {
                    return mallInfo;
                }
            }
        }
        return null;
    }

    /**
     * 系统开放现金礼包通过档位编号获取商品信息（知道活动编号）
     */
    public static MallInfo getSystemOpenRMBActivityMallInfoByGrade(int activityId, int grade) {
        Map<Integer, MallInfo> mallInfoMap = getActivityMallInfoMap(activityId);
        if (null != mallInfoMap) {
            for (MallInfo mallInfo : mallInfoMap.values()) {
                if (Integer.parseInt(mallInfo.getExtendParam()) == grade) {
                    return mallInfo;
                }
            }
        }
        return null;
    }

    public static int getGradeByMallId(int activityId, int mallId) {
        Map<Integer, MallInfo> mallInfoMap = getActivityMallInfoMap(activityId);
        if (mallInfoMap != null) {
            MallInfo mallInfo = mallInfoMap.get(mallId);
            if (mallInfo != null) {
                return Integer.parseInt(mallInfo.getExtendParam());
            }
        }
        return 0;
    }

    public static int getIndexByMallId(int activityId, int conditionId, int mallId) {
        Map<Integer, MallInfo> mallInfoMap = getActivityMallInfoMap(activityId);
        if (mallInfoMap != null) {
            MallInfo mallInfo = mallInfoMap.get(mallId);
            if (mallInfo != null) {
                int grade = Integer.parseInt(mallInfo.getExtendParam());
                ActivityConditionInfo activityConditionInfo = getActivityConditionInfo(activityId, conditionId);
                List<Integer> mallGradeList = StringUtils.stringToIntegerList(activityConditionInfo.getExtendParam(), "\\|");
                return mallGradeList.indexOf(grade);
            }
        }
        return 0;
    }

    public static int getMaxIndex(int activityId, int conditionId) {
        ActivityConditionInfo activityConditionInfo = getActivityConditionInfo(activityId, conditionId);
        List<Integer> mallGradeList = StringUtils.stringToIntegerList(activityConditionInfo.getExtendParam(), "\\|");
        return mallGradeList.size() - 1;
    }

    /**
     * 通过商店类型以及扩展参数id 获取商品类型
     */
    public static MallInfo getRMBActivityMallInfoByShopTypeAndExtendParam(int activityId, int shopType, int extendParamId) {
        Map<Integer, MallInfo> mallInfoMap = getActivityMallInfoMap(activityId);
        if (null != mallInfoMap) {
            for (MallInfo mallInfo : mallInfoMap.values()) {
                if (mallInfo.getShopType() == shopType && Integer.parseInt(mallInfo.getExtendParam()) == extendParamId) {
                    return mallInfo;
                }
            }
        }
        return null;
    }

    /**
     * 获取活动商品
     */
    public static MallInfo getActivityMallInfo(int mallId) {
        MallInfo mallInfo;
        List<ActivityInfo> activityInfoList = getShowTimeActivityInfoList();
        for (ActivityInfo activityInfo : activityInfoList) {
            Map<Integer, MallInfo> mallInfoMap = getActivityMallInfoMap(activityInfo.getActivityId());
            if (null != mallInfoMap) {
                mallInfo = mallInfoMap.get(mallId);
                if (null != mallInfo) {
                    return mallInfo;
                }
            }
        }
        return null;
    }

    /**
     * 获取全部活动条件数据
     */
    public static Map<Integer, List<ActivityConditionInfo>> getActivityConditionInfoMap() {
        return activityConditionInfoMap;
    }

    /**
     * 获取活动条件数据
     */
    public static List<ActivityConditionInfo> getActivityConditionInfoList(int activityId) {
        return activityConditionInfoMap.get(activityId);
    }

    /**
     * 获取活动条件数据
     */
    public static Map<Integer, List<ActivityConditionInfo>> getActivityConditionInfoMap(int activityId) {
        Map<Integer, List<ActivityConditionInfo>> dataMap = new ConcurrentHashMap<>();
        List<ActivityConditionInfo> dataList = getActivityConditionInfoList(activityId);
        if (null != dataList) {
            for (ActivityConditionInfo conditionInfo : dataList) {
                if (!dataMap.containsKey(conditionInfo.getType())) {
                    dataMap.put(conditionInfo.getType(), new ArrayList<>());
                }
                dataMap.get(conditionInfo.getType()).add(conditionInfo);
            }
        }
        return dataMap;
    }

    public static boolean hasConditionType(int activityId, int conditionType) {
        List<ActivityConditionInfo> dataList = getActivityConditionInfoList(activityId);
        if(null == dataList){
            return false;
        }
        for (ActivityConditionInfo conditionInfo : dataList) {
            if (conditionInfo.getType() == conditionType) {
                return true;
            }
        }
        return false;
    }

    /**
     * 根据条件编号获取条件信息
     */
    public static ActivityConditionInfo getActivityConditionInfo(int activityId, int conditionId) {
        List<ActivityConditionInfo> conditionInfoList = getActivityConditionInfoList(activityId);
        if(null == conditionInfoList){
            return null;
        }
        for (ActivityConditionInfo activityConditionInfo : conditionInfoList) {
            if (activityConditionInfo.getConditionId() == conditionId) {
                return activityConditionInfo;
            }
        }
        return null;
    }

    /**
     * 根据条件类型获取条件集合
     */
    public static List<ActivityConditionInfo> getActivityConditionInfoListByType(int activityId, int conditionType) {
        List<ActivityConditionInfo> list = new ArrayList<>();
        List<ActivityConditionInfo> conditionInfoList = getActivityConditionInfoList(activityId);
        if (null != conditionInfoList) {
            for (ActivityConditionInfo activityConditionInfo : conditionInfoList) {
                if (activityConditionInfo.getType() == conditionType) {
                    list.add(activityConditionInfo);
                }
            }
        }
        return list;
    }

    /**
     * 根据条件类型获取条件集合 key=mallKey
     */
    public static Map<Integer, List<ActivityConditionInfo>> getActivityConditionInfoMallKeyMapByType(int activityId, int conditionType) {
        Map<Integer, List<ActivityConditionInfo>> infoMap = new HashMap<>();
        List<ActivityConditionInfo> conditionInfoList = getActivityConditionInfoList(activityId);
        if (null != conditionInfoList) {
            for (ActivityConditionInfo activityConditionInfo : conditionInfoList) {
                if (activityConditionInfo.getType() == conditionType) {
                    int mallKey = activityConditionInfo.getParamList().get(0).intValue();
                    if (mallKey == 0) {
                        continue;
                    }
                    List<ActivityConditionInfo> infos = infoMap.get(mallKey);
                    if (infos == null) {
                        infos = new ArrayList<>();
                        infoMap.put(mallKey, infos);
                    }
                    infos.add(activityConditionInfo);
                }
            }
        }
        return infoMap;
    }

    /**
     * 获取战令礼包条件信息
     *
     * @param activityId
     * @return
     */
    public static List<ActivityConditionInfo> getZhanLingActivityConditionInfoList(int activityId) {
        List<ActivityConditionInfo> activityConditionInfoList = new ArrayList<>();
        List<ActivityConditionInfo> conditionInfoList = getActivityConditionInfoList(activityId);
        if (null != conditionInfoList) {
            for (ActivityConditionInfo activityConditionInfo : conditionInfoList) {
                if (activityConditionInfo.getType() == eGamePlayerEventType.ZhanLingMeiLiGiftBag.getValue()
                        || activityConditionInfo.getType() == eGamePlayerEventType.ZhanLingQinMiGiftBag.getValue()
                        || activityConditionInfo.getType() == eGamePlayerEventType.ZhanLingMenKeGiftBag.getValue()
                        || activityConditionInfo.getType() == eGamePlayerEventType.ZhanLingZhuanSuGiftBag.getValue()
                        || activityConditionInfo.getType() == eGamePlayerEventType.ZhanLingYuanBaoGiftBag.getValue()) {
                    activityConditionInfoList.add(activityConditionInfo);
                }
            }
        }
        return activityConditionInfoList;
    }

    /**
     * 根据活动排名获取条件信息
     */
    public static ActivityConditionInfo getActivityConditionInfoByRank(int activityId, int rank) {
        List<ActivityConditionInfo> conditionInfoList = getActivityConditionInfoList(activityId);
        if(null != conditionInfoList) {
            for (ActivityConditionInfo activityConditionInfo : conditionInfoList) {
                if (rank >= activityConditionInfo.getParamList().get(0).intValue() && rank <= activityConditionInfo.getParamList().get(1).intValue()) {
                    return activityConditionInfo;
                }
            }
        }
        return null;
    }

    public static ActivityConditionInfo getActivityConditionInfoByRankAndType(int activityId, int conditionType, int rank) {
        List<ActivityConditionInfo> conditionInfoList = getActivityConditionInfoList(activityId);
        if(null != conditionInfoList) {
            for (ActivityConditionInfo activityConditionInfo : conditionInfoList) {
                if (activityConditionInfo.getType() == conditionType) {
                    if (rank >= activityConditionInfo.getParamList().get(0).intValue() && rank <= activityConditionInfo.getParamList().get(1).intValue()) {
                        return activityConditionInfo;
                    }
                }
            }
        }
        return null;
    }

    public static ActivityConditionInfo getActivityConditionInfoBy2Rank(int activityId, int conditionType, int bigRank, int smallRank) {
        List<ActivityConditionInfo> conditionInfoList = getActivityConditionInfoList(activityId);
        if (null != conditionInfoList) {
            for (ActivityConditionInfo activityConditionInfo : conditionInfoList) {
                if (activityConditionInfo.getType() == conditionType) {
                    if (activityConditionInfo.getParamList().get(2).intValue() == bigRank) {
                        if (smallRank >= activityConditionInfo.getParamList().get(0).intValue() && smallRank <= activityConditionInfo.getParamList().get(1).intValue()) {
                            return activityConditionInfo;
                        }
                    }
                }
            }
        }
        return null;
    }

    public static UserActivityConditionData initUserActivityConditionData(long userId, String nickName, BigInteger value, int activityId, int conditionId, int type) {
        UserActivityConditionData userActivityConditionData;
        userActivityConditionData = new UserActivityConditionData();
        userActivityConditionData.setUserId(userId);
        userActivityConditionData.setActivityId(activityId);
        userActivityConditionData.setConditionId(conditionId);
        userActivityConditionData.setType(type);
        userActivityConditionData.setGetReward(false);
        userActivityConditionData.setValue(value);
        userActivityConditionData.setModifyTime(System.currentTimeMillis() / 1000);
        userActivityConditionData.setInsertOption();
        return userActivityConditionData;
    }

    public static boolean isActivityAutoSendReward(int activityId) {
        ActivityDetail activityDetail = activityDetailMap.get(activityId);
        if (null == activityDetail) {
            return true;
        }
        return activityDetail.getAutoSendRewardState() == 1;
    }

    /**
     * 根据最近购买信息获取商品
     *
     * @param player
     * @param lastData 最近信息
     * @param activityConditionInfo 活动
     * @param mallGradeList 商品档位编号数组
     * @param type 类型，0：不变档位；1：升档；2：降档
     * @return
     */
    public static MallInfo getMallInfoByLastMall(GamePlayer player, UserActivityConditionData lastData, ActivityConditionInfo activityConditionInfo, List<Integer> mallGradeList, int type) {
        ActivityConditionInfo lastActivityConditionInfo = NormalActivityMgr.getActivityConditionInfo(lastData.getActivityId(), lastData.getConditionId());
        List<Integer> lastMallGradeList = StringUtils.stringToIntegerList(lastActivityConditionInfo.getExtendParam(), "\\|");
        int index = 0;
        int lastMallId = lastData.getValue().intValue();

        for (int i = 0; i < lastMallGradeList.size(); i++) {
            MallInfo tempMall = getRMBActivityMallInfoByGrade(activityConditionInfo.getActivityId(), lastMallGradeList.get(i));
            if (null != tempMall && tempMall.getMallId() == lastMallId) {
                index = i;
                break;
            }
        }

        if (1 == type) {
            index += 1;
        } else if (2 == type) {
            index -= 1;
        }
        if (index < 0) {
            index = 0;
        }
        int maxIndex = mallGradeList.size() - 1;
        if (index > maxIndex) {
            index = maxIndex;
        }

        //基础档位
        if (player.getModule(AttributeModule.class).getAttribute(ePlayerAttrType.RechargeBaseIndex) > 0) {
            index = (int) (player.getModule(AttributeModule.class).getAttribute(ePlayerAttrType.RechargeBaseIndex) - 1);
            if (index > maxIndex) {
                index = maxIndex;
            }
        } else {
            player.getModule(AttributeModule.class).setAttribute(ePlayerAttrType.RechargeBaseIndex, index + 1);
        }

        int vipLowerLimitMallGrade = activityConditionInfo.getParamList().get(1).intValue();
        if (vipLowerLimitMallGrade > mallGradeList.get(index)) {
            //小R，不按最高档，该降低得降
            int vipLv = VipMgr.getVipLv(player.getUserInfo().getVipExp());
            boolean isSmallR = isSmallR(activityConditionInfo.getActivityId(), vipLv);
            if (!isSmallR && vipLv >= activityConditionInfo.getParamList().get(0).intValue()) {
                index = mallGradeList.indexOf(vipLowerLimitMallGrade);
            }
        }
        int grade = activityConditionInfo.getParamList().get(2).intValue();
        if (grade > 0) {
            int pushGiftNum = Integer.parseInt(NormalActivityMgr.getActivityInfo(activityConditionInfo.getActivityId()).getParam5());
            pushGiftNum = pushGiftNum > 0 ? pushGiftNum : 1;
            int pushMinIndex;
            int pushMaxIndex = index;
            if (index - (pushGiftNum - 1) >= 0) {
                pushMinIndex = index - (pushGiftNum - 1);
            } else {
                pushMinIndex = 0;
                pushMaxIndex = pushGiftNum  - 1;
            }
            if (mallGradeList.indexOf(grade) >= pushMinIndex && mallGradeList.indexOf(grade) <= pushMaxIndex) {
                return getRMBActivityMallInfoByGrade(activityConditionInfo.getActivityId(), grade);
            }
        } else if (Integer.parseInt(NormalActivityMgr.getActivityInfo(activityConditionInfo.getActivityId()).getParam5()) == 0) {
            return getRMBActivityMallInfoByGrade(activityConditionInfo.getActivityId(), mallGradeList.get(index));
        }
        return null;
    }

    public static boolean isSmallR(int activityId, int vipLv) {
        boolean isSmallR = false;
        int day = openDayByGearRevision(activityId, vipLv);
        if(day > 0){
            isSmallR = ServerListMgr.getServerOpenDay(GameServer.getInstance().getServerId()) > day;
        }
        return isSmallR;
    }

    /**
     * 是否出过现金礼包
     */
    public static boolean isShowRMBMall(List<UserActivityConditionData> userActivityConditionDataList) {
        if (null != userActivityConditionDataList) {
            for (UserActivityConditionData data : userActivityConditionDataList) {
                if (data.getValue().compareTo(BigInteger.ZERO) > 0) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 获取现金礼包的超时时间
     * @param activityInfo
     * @return
     */
    public static int getRMBMallOverTime(ActivityInfo activityInfo) {
        String[] paramArr = activityInfo.getParam6().split("\\|");
        return Integer.parseInt(paramArr[0]);
    }

    /**
     * 获取现金礼包的冷却时间
     * @param activityInfo
     * @return
     */
    public static int getRMBMallCDTime(ActivityInfo activityInfo) {
        String[] paramArr = activityInfo.getParam6().split("\\|");
        return Integer.parseInt(paramArr[1]);
    }


    /**
     * 获取开放的冲榜活动列表（新的冲榜活动）
     */
    public static List<ActivityInfo> getNewRankActivityInfoList() {
        List<ActivityInfo> activityList = new ArrayList<>();
        long nowTime = System.currentTimeMillis() / 1000;
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            eUnionActivityGroupType groupType = eUnionActivityGroupType.getType(activityInfo.getType());
            if (groupType != null) {//商会分组活动,不用这个协议更新
                continue;
            }
            if (activityInfo.getEndShowTime() > nowTime && (
                    activityInfo.getType() == eActivityType.PageantActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CrossHolidayActivity.getValue() ||
                    activityInfo.getType() == eActivityType.ThrowingPotActivity.getValue() ||
                    activityInfo.getType() == eActivityType.YearMasterActivity.getValue() ||
                    activityInfo.getType() == eActivityType.TreasureActivity.getValue() ||
                    activityInfo.getType() == eActivityType.PplActivity.getValue() ||
                    activityInfo.getType() == eActivityType.JianChuangHuaActivity.getValue() ||
                    activityInfo.getType() == eActivityType.DrawPicturesActivity.getValue() ||
                    activityInfo.getType() == eActivityType.DaFuWeng.getValue() ||
                    activityInfo.getType() == eActivityType.TangHuluActivity.getValue() ||
                    activityInfo.getType() == eActivityType.ShuiHuActivity.getValue() ||
                    activityInfo.getType() == eActivityType.BowArtActivity.getValue() ||
                    activityInfo.getType() == eActivityType.GhostActivity.getValue() ||
                    activityInfo.getType() == eActivityType.PawnshopActivity.getValue() ||
                    activityInfo.getType() == eActivityType.SuoYaoActivity.getValue() ||
                    activityInfo.getType() == eActivityType.BusyFarmingActivity.getValue() ||
                    activityInfo.getType() == eActivityType.GuGuoXunBaoActivity.getValue() ||
                    activityInfo.getType() == eActivityType.HangHaiActivity.getValue() ||
                    activityInfo.getType() == eActivityType.DrinkActivity.getValue() ||
                    activityInfo.getType() == eActivityType.DragonBoatRaceActivity.getValue() ||
                    activityInfo.getType() == eActivityType.XiaYueActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CrossDunHuangShiKuActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CelebrationActivity.getValue() ||
                    activityInfo.getType() == eActivityType.LanRuoSiActivity.getValue() ||
                    activityInfo.getType() == eActivityType.GourdChildActivity.getValue() ||
                    activityInfo.getType() == eActivityType.WinterLoveActivity.getValue() ||
                    activityInfo.getType() == eActivityType.YingXinActivity.getValue()||
                    activityInfo.getType() == eActivityType.HellActivity.getValue()||
                    activityInfo.getType() == eActivityType.XiaowuRecallActivity.getValue() ||
                    activityInfo.getType() == eActivityType.DouLuoDaLuActivity.getValue() ||
                    activityInfo.getType() == eActivityType.DouLuoShrekActivity.getValue()||
                    activityInfo.getType() == eActivityType.ShuiHuYeZiCardActivity.getValue()||
                    activityInfo.getType() == eActivityType.SpringDinner.getValue() ||
                    activityInfo.getType() == eActivityType.SeacraftActivity.getValue()||
                    activityInfo.getType() == eActivityType.ToyHouse.getValue()||
                    activityInfo.getType() == eActivityType.ChineseChess.getValue() ||
                    activityInfo.getType() == eActivityType.ShuShanActivity.getValue() ||
                    activityInfo.getType() == eActivityType.ZhouNianTurntable.getValue() ||
                    activityInfo.getType() == eActivityType.ClimbTower.getValue() ||
                    activityInfo.getType() == eActivityType.OperaMask.getValue() ||
                    activityInfo.getType() == eActivityType.UnionRankActivity.getValue()||
                    activityInfo.getType() == eActivityType.FellingTrees.getValue()||
                    activityInfo.getType() == eActivityType.Pasture.getValue() ||
                    activityInfo.getType()==eActivityType.Tomb.getValue() ||
                    activityInfo.getType() == eActivityType.GreatTradeActivity.getValue() ||
                    activityInfo.getType() == eActivityType.Twins.getValue() ||
                    activityInfo.getType() == eActivityType.CricketSeasonActivity.getValue() ||
                    activityInfo.getType() == eActivityType.Cat.getValue() ||
                    activityInfo.getType() == eActivityType.WorldCup.getValue() ||
                    activityInfo.getType() == eActivityType.PeakStrongHold.getValue() ||
                    activityInfo.getType() == eActivityType.LionDance.getValue() ||
                    activityInfo.getType() == eActivityType.CarpTripActivity.getValue() ||
                    activityInfo.getType() == eActivityType.FireWork2023.getValue() ||
                    activityInfo.getType() == eActivityType.FanXiuSpringActivity.getValue() ||
                    activityInfo.getType() == eActivityType.CommonWishDraw.getValue() ||
                    activityInfo.getType() == eActivityType.XiuXian.getValue() ||
                    activityInfo.getType() == eActivityType.Feast.getValue() ||
                    activityInfo.getType() == eActivityType.FlowerCards.getValue() ||
                    activityInfo.getType() == eActivityType.GoldAutumn.getValue() ||
                    activityInfo.getType() == eActivityType.JieShi.getValue() ||
                    activityInfo.getType() == eActivityType.PeakSeacraftActivity.getValue() ||
                    activityInfo.getType() == eActivityType.PeerlessBeautyLotteryActivity.getValue() ||
                    activityInfo.getType() == eActivityType.GoddessActivity.getValue() ||
                    activityInfo.getType() == eActivityType.LangYaMemorial.getValue() ||
                    activityInfo.getType() == eActivityType.DeepFishing.getValue() ||
                    activityInfo.getType() == eActivityType.LangYaBang.getValue() ||
                    activityInfo.getType() == eActivityType.SilkRoad.getValue() ||
                    activityInfo.getType() == eActivityType.FlowerStudy.getValue() ||
                    activityInfo.getType() == eActivityType.WanYao.getValue() ||
                    activityInfo.getType() == eActivityType.QiXiActivity.getValue() ||
                    activityInfo.getType() == eActivityType.GuaGiftsActivity.getValue() ||
                    activityInfo.getType() == eActivityType.DigGold.getValue() ||
                    activityInfo.getType() == eActivityType.EveFeast.getValue() ||
                    activityInfo.getType() == eActivityType.DaoMu.getValue() ||
                    activityInfo.getType() == eActivityType.WitchDraw.getValue() ||
                    activityInfo.getType() == eActivityType.SteleSoul.getValue() ||
                    activityInfo.getType() == eActivityType.MusicRoomRank.getValue() ||
                    activityInfo.getType() == eActivityType.SnowGarden.getValue() ||
                    activityInfo.getType() == eActivityType.ActivityFund.getValue() ||
                    activityInfo.getType() == eActivityType.RuiShou.getValue() ||
                    activityInfo.getType() == eActivityType.ZhenHuan.getValue() ||
                    activityInfo.getType() == eActivityType.BiaoJu.getValue() ||
                    activityInfo.getType() == eActivityType.SpringDraw.getValue() ||
                    activityInfo.getType() == eActivityType.FoxCard.getValue() ||
                    activityInfo.getType() == eActivityType.HongXianActivity.getValue() ||
                    activityInfo.getType() == eActivityType.SummerGames.getValue() ||
                    activityInfo.getType() == eActivityType.Harps.getValue() ||
                    activityInfo.getType() == eActivityType.SonHai.getValue() ||
                    activityInfo.getType() == eActivityType.HsIsland.getValue() ||
                    activityInfo.getType() == eActivityType.Turtle.getValue() ||
                    activityInfo.getType() == eActivityType.HotpotJump.getValue() ||
                    activityInfo.getType() == eActivityType.Gashapon.getValue() ||
                    activityInfo.getType() == eActivityType.Apprentice.getValue() ||
                    activityInfo.getType() == eActivityType.XingYouShanShui.getValue() ||
                    (activityInfo.getType() == eActivityType.ChefDuel.getValue() && activityInfo.getChildType() == eChefDuelActivityType.Phase1.getChildType()) ||
                    activityInfo.getType() == eActivityType.YQHotel.getValue()
            )) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    public static int getActivityRankNumByActivityParam(ActivityInfo activityInfo) {
        if (activityInfo.getType() == eActivityType.CrossHolidayActivity.getValue()) {
            return 0;
        }
        int rankNum = Integer.parseInt(activityInfo.getParam6());
        return rankNum;
    }

    public static List<Integer> getActivityConditionUserRankType(int activityId) {
        List<Integer> list = new ArrayList<>();
        Map<Integer, List<ActivityConditionInfo>> activityConditionInfoMap = getActivityConditionInfoMap(activityId);
        if (activityConditionInfoMap == null) {
            return list;
        }
        for (Integer type : activityConditionInfoMap.keySet()) {
            if (ActivityHelper.isUserRankType(type)) {
                list.add(type);
            }
        }
        return list;
    }

    public static List<Integer> getActivityConditionUnionRankType(int activityId) {
        List<Integer> list = new ArrayList<>();
        Map<Integer, List<ActivityConditionInfo>> activityConditionInfoMap = getActivityConditionInfoMap(activityId);
        if (activityConditionInfoMap == null) {
            return list;
        }
        for (Integer type : activityConditionInfoMap.keySet()) {
            if (ActivityHelper.isUnionRankType(type)) {
                list.add(type);
            }
        }
        return list;
    }

    /**
     * 是否达到精进赚钱基金的最低档次目标
     * @return
     */
    public static boolean isEarnMoneyFundMinGoalCompete(GamePlayer player) {
        List<ActivityInfo> openActivityInfoList = getOpenActivityInfoList(eActivityType.WelfareActivity.getValue());
        for (ActivityInfo activityInfo : openActivityInfoList) {
            if (activityInfo.getChildType() == eWelfareActivityType.EarnMoneyPlusFund.getValue()) {
                List<ActivityConditionInfo> activityConditionInfoList = getActivityConditionInfoList(activityInfo.getActivityId());
                ArrayList<ActivityConditionInfo> tempList;
                if(null != activityConditionInfoList){
                    tempList = new ArrayList<>(activityConditionInfoList);
                }else {
                    tempList = new ArrayList<>();
                }
                tempList.sort((o1, o2) -> {
                    BigInteger o1Value = o1.getParamList().get(3);
                    BigInteger o2Value = o2.getParamList().get(3);
                    return o1Value.compareTo(o2Value);
                });
                if (tempList.size() > 0) {
                    return player.getModule(ActivityModule.class).isUnlockEarnSpeedPlusFund(tempList.get(0));
                }
            }
        }
        return false;
    }

    /**
     * 是否达能购买倾城基金
     * @return
     */
    public static boolean isBeautyHigherFundCanBuy(GamePlayer player) {
        List<ActivityInfo> openActivityInfoList = getOpenActivityInfoList(eActivityType.WelfareActivity.getValue());
        for (ActivityInfo activityInfo : openActivityInfoList) {
            if (activityInfo.getChildType() == eWelfareActivityType.BeautyHigherFund.getValue()) {
                List<ActivityConditionInfo> activityConditionInfoList = getActivityConditionInfoList(activityInfo.getActivityId());
                ArrayList<ActivityConditionInfo> tempList = new ArrayList<>(activityConditionInfoList);
                tempList.sort((o1, o2) -> {
                    BigInteger o1Value = o1.getParamList().get(3);
                    BigInteger o2Value = o2.getParamList().get(3);
                    return o1Value.compareTo(o2Value);
                });
                if (tempList.size() > 0) {
                    return player.getModule(ActivityModule.class).isUnlockBeautyHigerFund(tempList.get(0));
                }
            }
        }
        return false;
    }

    /**
     * 聊天活动列表
     * @return
     */
    public static List<ActivityInfo> getChatActivityList(){
        List<ActivityInfo> activityList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) &&
                    activityInfo.getType() == eActivityType.PlatformActivity.getValue() &&
                    activityInfo.getChildType() == 41
            ) {
                activityList.add(activityInfo);
            }
        }
        return activityList;
    }

    /**
     * 获取开启中的跨地区活动info
     */
    public static List<ActivityInfo> getShowTimeChannelActivityInfo() {
        List<ActivityInfo> list = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            // 跨地区类型 && showTime
            if (ActivityHelper.isCrossChannelActivityType(activityInfo.getType()) && ActivityMgr.activityInShowTime(activityInfo)) {
                list.add(activityInfo);
            }
        }
        return list;
    }

    public static List<Integer> getOpenWineryAromaRankActivityIdList(){
        List<Integer> activityIdList = new ArrayList<>();
        for (ActivityInfo activityInfo : showTimeActivityInfoMap.values()) {
            if (ActivityMgr.activityInShowTime(activityInfo) &&
                    ((activityInfo.getType() == eActivityType.RankActivity.getValue() && activityInfo.getChildType() == eRankActivityType.WineryAromaRiseRank.getValue())
                            || (activityInfo.getType() == eActivityType.CrossRankActivity.getValue() && activityInfo.getChildType() == eCrossRankActivityType.CrossWineryAromaRiseRank.getValue()))) {
                activityIdList.add(activityInfo.getActivityId());
            }
        }
        return activityIdList;
    }

    public static int openDayByGearRevision(int activityId, int vipLv){
        try{
            Map<Integer, Integer> map = triggerRevisionMap.get(activityId);
            if(map == null){
                map = new HashMap<>();
                Map<String, ActivityConfig> activityConfigMap = NormalActivityMgr.getActivityConfigMap(activityId);
                if(activityConfigMap != null){
                    ActivityConfig activityConfig = activityConfigMap.get("TRIGGER_PACKAGES_GEAR_REVISION");
                    if(activityConfig != null){
                        List<String> stringList = StringUtils.stringToStringList(activityConfig.getValue(), "\\|");
                        for (String str : stringList) {
                            List<Integer> list = StringUtils.stringToIntegerList(str, ";");
                            if(list.size() == 2){
                                map.put(list.get(1), list.get(0));
                            }
                        }
                        triggerRevisionMap.put(activityId, map);
                    }
                }
            }
            return map.getOrDefault(vipLv, 0);
        }catch (Exception e){
            logger.error("", e);
        }
        return 0;
    }
}
